2011年12月26日 星期一

XML 解析

Q: 讀入一個字串,如何取出節點的值?
A:
Dim xmltext As New System.Text.StringBuilder
Dim strReader As StringReader = New StringReader(mXml)
Dim reader As XmlTextReader = New XmlTextReader(strReader)
Dim docNav As New XPathDocument(reader)
Dim objxPath As XPathNavigator = docNav.CreateNavigator
Dim objNode As XPathNavigator = objxPath.SelectSingleNode("/")
Return objNode.Value