question updated: for clarification, sorry if my question is not clear.
here we go. what im trying to do here is change the tag name of a spefic tag based on its attribute, and delete the attribute
in this example i need to change Emphasis name with attribute italic to i tag name, and para textbreak="no" to p tag
here is how i populate my listview
//add data to listview this.lvContent.Items.Add(new MyItem { Tag = "Emphasis", Attribute = "Type", Value = "Italic", NewTag = "i" }); this.lvContent.Items.Add(new MyItem { Tag = "Para", Attribute = "TextBreak", Value = "No", NewTag = "p" }); foreach (MyItem item in lvContent.Items) { XElement rootI = XElement.Parse(txtInput.Text); IEnumerable<XElement> Emphasis = from el in rootI.Descendants("" + item.Tag + "") where (string)el.Attribute("" + item.Attribute + "") == "" + item.Value + "" select el; foreach (XElement el in Emphasis) { el.Name = "" + item.NewTag + ""; } XElement xdoc = XElement.Parse(rootI.ToString()); var elementsToRemove = from elemet in xdoc.Descendants(item.NewTag) where elemet.Attribute(item.Attribute).Value == item.Value select elemet; foreach (var ee in elementsToRemove) { if (ee.Attribute(item.Attribute).Value == item.Value) { ee.RemoveAttributes(); } } Console.WriteLine(xdoc.ToString()); } the output of the program
<Abstract> <Heading>Abstract</Heading> <Para TextBreak="No">Some paragraph <i>q</i></Para> </Abstract> <Abstract> <Heading>Abstract</Heading> <p>Some paragraph <Emphasis Type="Italic">q</Emphasis></p> </Abstract> and this is the correct output
<Abstract> <Heading>Abstract</Heading> <p>Some paragraph <i>q</i></p> </Abstract> the reason im asking how to pass the output of the first loop to the next loop is to
be used as INPUT to the next loop is because of the output.
i hope my question is clear now.