i need to make parser to go trough node tree
i have this structure
<root>
<bookstore pass="1">
<book>
<name id="1">programm ing xml</name>
</book>
<book>
<name id="2">programm ing 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">programm ing xml</name>
</katalog>
</book>
<book>
<name id="2">programm ing 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(s tring id, string path, XPathNavigator nav,
XmlTextWriter writer)
{
XPathNodeIterat or iter = nav.Select(path );
while (iter.MoveNext( ))
{
if (iter.Current.G etAttribute("id ", "") == id)
{
//change this node text with text from first file
}
writer.WriteSta rtElement(iter. Current.Name);
if (iter.Current.H asChildren)
{
//dont know how to get children path to put it in recursion
ParseNodeTree(i d, path, nav, writer);
}
else
{
writer.WriteFul lEndElement();
}
}
}
can someone please help me. i lost 2 days for this
i cant do it anymore
thanks!
i have this structure
<root>
<bookstore pass="1">
<book>
<name id="1">programm ing xml</name>
</book>
<book>
<name id="2">programm ing 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">programm ing xml</name>
</katalog>
</book>
<book>
<name id="2">programm ing 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(s tring id, string path, XPathNavigator nav,
XmlTextWriter writer)
{
XPathNodeIterat or iter = nav.Select(path );
while (iter.MoveNext( ))
{
if (iter.Current.G etAttribute("id ", "") == id)
{
//change this node text with text from first file
}
writer.WriteSta rtElement(iter. Current.Name);
if (iter.Current.H asChildren)
{
//dont know how to get children path to put it in recursion
ParseNodeTree(i d, path, nav, writer);
}
else
{
writer.WriteFul lEndElement();
}
}
}
can someone please help me. i lost 2 days for this
i cant do it anymore
thanks!
Comment