Hi,
I am tryin to navigate through an XMLDocument using XPathNavigator. PagesXML is a valid xmldocument and i am trying to assign it to xpathDoc by casting it. But I am getting a 'Specified cast is invalid' message. How can I navigate through the XML?
Dim getSurveyPagesXML As New getSurveyXML
Dim PagesXML As XmlDocument = getSurveyPagesXML.getXML(strFolder, "pages")
Dim xpathDoc As XPathDocument
Dim xmlNav As XPathNavigator
Dim xmlNI As XPathNodeIterator
Try
xpathDoc = DirectCast(PagesXML, XPathDocument)
xmlNav = xpathDoc.CreateNavigator()
xmlNI = xmlNav.Select("/list_pages/page")
While (xmlNI.MoveNext())
System.Console.WriteLine(xmlNI.Current.Name + " : " + xmlNI.Current.Value)
End While
Catch ex As XPathException
System.Console.WriteLine("XMLException: " + ex.Message)
Catch ex As Exception
System.Console.WriteLine("Exception: " + ex.Message)
End Try
I am tryin to navigate through an XMLDocument using XPathNavigator. PagesXML is a valid xmldocument and i am trying to assign it to xpathDoc by casting it. But I am getting a 'Specified cast is invalid' message. How can I navigate through the XML?
Dim getSurveyPagesXML As New getSurveyXML
Dim PagesXML As XmlDocument = getSurveyPagesXML.getXML(strFolder, "pages")
Dim xpathDoc As XPathDocument
Dim xmlNav As XPathNavigator
Dim xmlNI As XPathNodeIterator
Try
xpathDoc = DirectCast(PagesXML, XPathDocument)
xmlNav = xpathDoc.CreateNavigator()
xmlNI = xmlNav.Select("/list_pages/page")
While (xmlNI.MoveNext())
System.Console.WriteLine(xmlNI.Current.Name + " : " + xmlNI.Current.Value)
End While
Catch ex As XPathException
System.Console.WriteLine("XMLException: " + ex.Message)
Catch ex As Exception
System.Console.WriteLine("Exception: " + ex.Message)
End Try