i need to make parser to go trough node tree
i have this structure
<root>
<bookstore pass="1">
<book>
<name id="1">programming xml</name>
</book>
<book>
<name id="2">programming C#</name>
</book>
</bookstore>
</root>
which is not same all the time. sometimes it have more element in book and
sometimes is deeper like this.
this is just example xml
<root>
<bookstore pass="1">
<book>
<katalog num="1">
<name id="1">programming xml</name>
</katalog>
</book>
<book>
<name id="2">programming C#</name>
</book>
</bookstore>
</root>
i have 3 xml files
first xml where i read data and if i have attribute in bookstore i go and check
for name attribute. i took it and than i go to bookstore tag with same
attribute in second xml. and i need to write all elements in bookstore to third
xml (same structure), but i need to change name tag innertext with text from
first xml.
i was thinking
public void ParseNodeTree(string id, string path, XPathNavigator nav,
XmlTextWriter writer)
{
XPathNodeIterator iter = nav.Select(path);
while (iter.MoveNext())
{
if (iter.Current.GetAttribute("id", "") == id)
{
//change this node text with text from first file
}
writer.WriteStartElement(iter.Current.Name);
if (iter.Current.HasChildren)
{
//dont know how to get children path to put it in recursion
ParseNodeTree(id, path, nav, writer);
}
else
{
writer.WriteFullEndElement();
}
}
}
can someone please help me. i lost 2 days for this
i cant do it anymore
thanks!