G
Guest
Hi there,
I had this xml file with me (not yet consider implementing xml namespaces yet).
<?xml version='1.0'?>
<Object>
<Windows>
<EID>1</EID>
<EDesc>Error 1</EDesc>
</Windows>
<Windows>
<EID>2</EID>
<EDesc>Error 2</EDesc>
</Windows>
</Object>
My C# code:
private void button1_Click(object sender, System.EventArgs e)
{
try
{
XPathDocument xmldoc = new XPathDocument("IrisException.xml");
XPathNavigator nav = xmldoc.CreateNavigator();
XPathNodeIterator iterator;
try
{
iterator = nav.Select("//EID[. ='1']//parent::node()/EDesc");
}
catch(XPathException XPathExp)
{
Debug.WriteLine(XPathExp.Message);
return;
}
while (iterator.MoveNext())
{
Debug.WriteLine(iterator.Current.Value);
}
}
catch(Exception OtherExp)
{
Debug.WriteLine(OtherExp.Message);
}
}
I really don't want to use iterator. In the xml file, there is not extra occurence of a keyword.
Example,
1,2, 3,, 4, 5 - no occurence of same EID
1, 1, 3, 2, 2 - won't exist this in the xml file
How am i suppose to query using xpath 1 record only?
Please help! Thanks.
I had this xml file with me (not yet consider implementing xml namespaces yet).
<?xml version='1.0'?>
<Object>
<Windows>
<EID>1</EID>
<EDesc>Error 1</EDesc>
</Windows>
<Windows>
<EID>2</EID>
<EDesc>Error 2</EDesc>
</Windows>
</Object>
My C# code:
private void button1_Click(object sender, System.EventArgs e)
{
try
{
XPathDocument xmldoc = new XPathDocument("IrisException.xml");
XPathNavigator nav = xmldoc.CreateNavigator();
XPathNodeIterator iterator;
try
{
iterator = nav.Select("//EID[. ='1']//parent::node()/EDesc");
}
catch(XPathException XPathExp)
{
Debug.WriteLine(XPathExp.Message);
return;
}
while (iterator.MoveNext())
{
Debug.WriteLine(iterator.Current.Value);
}
}
catch(Exception OtherExp)
{
Debug.WriteLine(OtherExp.Message);
}
}
I really don't want to use iterator. In the xml file, there is not extra occurence of a keyword.
Example,
1,2, 3,, 4, 5 - no occurence of same EID
1, 1, 3, 2, 2 - won't exist this in the xml file
How am i suppose to query using xpath 1 record only?
Please help! Thanks.