Tree traversal
I am trying to search a xml documents. I can traverse the source document all the way down to the last child. For some reasons, the destination xml document can not traverse to the bottom like the source. please see code. Error shows Red line.
kwasi DenkyiraPosted Apr 21, 2010, 7:04 AM
//XPathDocument src = new XPathDocument(oSrcAllXMLReader);
XPathNavigator srcnav = oSrcXMLDoc.CreateNavigator();
//XPathDocument des = new XPathDocument(oDesXMLReader);
XPathNavigator desnav = oDesXmlDoc.CreateNavigator();
MessageBox.Show(desnav.OuterXml);
srcnav.MoveToRoot();
srcnav.MoveToFirstChild();
do
{
do
{
desnav.MoveToRoot();
desnav.MoveToFirstChild();
Boolean found = false;
do
{
do
{
if (srcnav.Name == desnav.Name)
{
string tmpval = srcnav.Value.ToString();
if (tmpval != null && tmpval.Length > 0)
{
desnav.SetValue(tmpval);
}
found = true;
}
} while (desnav.MoveToChild(XPathNodeType.Element) && found == false);
} while (desnav.MoveToNext(XPathNodeType.Element) && found == false);
} while (srcnav.MoveToChild(XPathNodeType.Element));
} while (srcnav.MoveToNext(XPathNodeType.Element));
MessageBox.Show(desnav.OuterXml);
Hirendra SisodiyaPosted Apr 21, 2010, 2:00 AM
Where are your code????
thanks