|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to retreive deepest XPath value from XML using VB.NETHi All,
Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like: Dim xmlDoc As XMLDocument Dim strXPath As String = xmlDoc.GetXPath() TIA Goran Djuranovic Here is the solution in VB.NET:
************************** Begin Code ******************************* Imports System.Xml Imports System.Xml.XPath _ Public Class TestXML 'Entry point which delegates to C-style main Private Function 'Public Overloads Shared Sub Main() ' Main(System.Environment.GetCommandLineArgs()) 'End Sub 'Public Overloads Shared Sub Main(ByVal args() As String) ' Dim xmlDocument As New XPathDocument("example.xml") ' Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") ' If Not (deepestElement Is Nothing) Then ' Console.WriteLine("Found element {0}.", deepestElement.Name) ' Console.WriteLine(("Path is " + GetXPath(deepestElement))) ' End If ' Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) ' If Not (deepestElement Is Nothing) Then ' Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) ' Console.WriteLine(("Path is " + GetXPath(deepestNode))) ' End If 'End Sub 'Main Public Sub New() End Sub Public Sub GetDeepestXPath() Dim xmlDocument As New XPathDocument("C:\xmltest.xml") Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") If Not (deepestElement Is Nothing) Then Console.WriteLine("Found element {0}.", deepestElement.Name) Console.WriteLine(("Path is " + GetXPath(deepestElement))) End If Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) If Not (deepestElement Is Nothing) Then Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) Console.WriteLine(("Path is " + GetXPath(deepestNode))) End If End Sub Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable) As XPathNavigator Return GetDeepestNode(xmlInput, "node()") End Function 'GetDeepestNode Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable, ByVal nodeTest As String) As XPathNavigator Dim xPathNavigator As XPathNavigator = xmlInput.CreateNavigator() Dim xPathExpression As XPathExpression = xPathNavigator.Compile(("//" + nodeTest)) xPathExpression.AddSort("count(ancestor::node())", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number) Dim nodeIterator As XPathNodeIterator = xPathNavigator.Select(xPathExpression) If nodeIterator.MoveNext() Then Return nodeIterator.Current Else Return Nothing End If End Function 'GetDeepestNode Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator) As String Return GetXPath(navigator, "") End Function 'GetXPath Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator, ByVal currentPath As String) As String Dim name As String = "" Select Case navigator.NodeType Case XPathNodeType.Root Return "/" + currentPath Case XPathNodeType.Element name = navigator.Name GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Comment name = "comment()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.ProcessingInstruction name = "processing-instruction()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Text CaseXPathNodeTypeDotText: If name = "" Then name = "text()" End If Dim position As Integer = Convert.ToInt32(CDbl(navigator.Evaluate(("count(preceding-sibling::" + name + ")")))) + 1 navigator.MoveToParent() Dim someString As String If currentPath <> "" Then 'someString = name & "[" & position & "]" & "/" & currentPath someString = name & "/" & currentPath Else 'someString = name & "[" & position & "]" someString = name End If 'Return GetXPath(navigator, name + "[" + position + "]" +(If currentPath <> "" Then "/" + CurrentPath Else "")) 'ToDo: Unsupported feature: conditional (?) operator. Return GetXPath(navigator, someString) Case Else Return "" End Select End Function 'GetXPath End Class 'Test ******************************************* End Code **************************************** Goran Djuranovic "Goran Djuranovic" <djurag@mmcREMOVE_TO_MAIL.org> wrote in message news:%23$jn9lLPGHA.536@TK2MSFTNGP09.phx.gbl... Hi All,Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like: Dim xmlDoc As XMLDocument Dim strXPath As String = xmlDoc.GetXPath() TIA Goran Djuranovic Here is the solution in VB.NET:
************************** Begin Code ******************************* Imports System.Xml Imports System.Xml.XPath _ Public Class TestXML 'Entry point which delegates to C-style main Private Function 'Public Overloads Shared Sub Main() ' Main(System.Environment.GetCommandLineArgs()) 'End Sub 'Public Overloads Shared Sub Main(ByVal args() As String) ' Dim xmlDocument As New XPathDocument("example.xml") ' Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") ' If Not (deepestElement Is Nothing) Then ' Console.WriteLine("Found element {0}.", deepestElement.Name) ' Console.WriteLine(("Path is " + GetXPath(deepestElement))) ' End If ' Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) ' If Not (deepestElement Is Nothing) Then ' Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) ' Console.WriteLine(("Path is " + GetXPath(deepestNode))) ' End If 'End Sub 'Main Public Sub New() End Sub Public Sub GetDeepestXPath() Dim xmlDocument As New XPathDocument("C:\xmltest.xml") Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") If Not (deepestElement Is Nothing) Then Console.WriteLine("Found element {0}.", deepestElement.Name) Console.WriteLine(("Path is " + GetXPath(deepestElement))) End If Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) If Not (deepestElement Is Nothing) Then Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) Console.WriteLine(("Path is " + GetXPath(deepestNode))) End If End Sub Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable) As XPathNavigator Return GetDeepestNode(xmlInput, "node()") End Function 'GetDeepestNode Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable, ByVal nodeTest As String) As XPathNavigator Dim xPathNavigator As XPathNavigator = xmlInput.CreateNavigator() Dim xPathExpression As XPathExpression = xPathNavigator.Compile(("//" + nodeTest)) xPathExpression.AddSort("count(ancestor::node())", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number) Dim nodeIterator As XPathNodeIterator = xPathNavigator.Select(xPathExpression) If nodeIterator.MoveNext() Then Return nodeIterator.Current Else Return Nothing End If End Function 'GetDeepestNode Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator) As String Return GetXPath(navigator, "") End Function 'GetXPath Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator, ByVal currentPath As String) As String Dim name As String = "" Select Case navigator.NodeType Case XPathNodeType.Root Return "/" + currentPath Case XPathNodeType.Element name = navigator.Name GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Comment name = "comment()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.ProcessingInstruction name = "processing-instruction()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Text CaseXPathNodeTypeDotText: If name = "" Then name = "text()" End If Dim position As Integer = Convert.ToInt32(CDbl(navigator.Evaluate(("count(preceding-sibling::" + name + ")")))) + 1 navigator.MoveToParent() Dim someString As String If currentPath <> "" Then 'someString = name & "[" & position & "]" & "/" & currentPath someString = name & "/" & currentPath Else 'someString = name & "[" & position & "]" someString = name End If 'Return GetXPath(navigator, name + "[" + position + "]" +(If currentPath <> "" Then "/" + CurrentPath Else "")) 'ToDo: Unsupported feature: conditional (?) operator. Return GetXPath(navigator, someString) Case Else Return "" End Select End Function 'GetXPath End Class 'Test ******************************************* End Code **************************************** Goran Djuranovic "Goran Djuranovic" <djurag@mmcREMOVE_TO_MAIL.org> wrote in message news:%23$jn9lLPGHA.536@TK2MSFTNGP09.phx.gbl... Hi All,Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like: Dim xmlDoc As XMLDocument Dim strXPath As String = xmlDoc.GetXPath() TIA Goran Djuranovic Goran,
please don't cross post to multiple groups. Your post is clearly intended for the vb language group; posting it to the C# group only serves to confuse people. Thanks, Peter -- Show quoteHide quoteCo-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com "Goran Djuranovic" wrote: > Here is the solution in VB.NET: > > ************************** Begin Code ******************************* > Imports System.Xml > > Imports System.Xml.XPath > > _ > > Public Class TestXML > > 'Entry point which delegates to C-style main Private Function > > 'Public Overloads Shared Sub Main() > > ' Main(System.Environment.GetCommandLineArgs()) > > 'End Sub > > 'Public Overloads Shared Sub Main(ByVal args() As String) > > ' Dim xmlDocument As New XPathDocument("example.xml") > > ' Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") > > ' If Not (deepestElement Is Nothing) Then > > ' Console.WriteLine("Found element {0}.", deepestElement.Name) > > ' Console.WriteLine(("Path is " + GetXPath(deepestElement))) > > ' End If > > ' Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) > > ' If Not (deepestElement Is Nothing) Then > > ' Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) > > ' Console.WriteLine(("Path is " + GetXPath(deepestNode))) > > ' End If > > 'End Sub 'Main > > Public Sub New() > > End Sub > > Public Sub GetDeepestXPath() > > Dim xmlDocument As New XPathDocument("C:\xmltest.xml") > > Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") > > If Not (deepestElement Is Nothing) Then > > Console.WriteLine("Found element {0}.", deepestElement.Name) > > Console.WriteLine(("Path is " + GetXPath(deepestElement))) > > End If > > Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) > > If Not (deepestElement Is Nothing) Then > > Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) > > Console.WriteLine(("Path is " + GetXPath(deepestNode))) > > End If > > End Sub > > > > Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable) As XPathNavigator > > Return GetDeepestNode(xmlInput, "node()") > > End Function 'GetDeepestNode > > > > Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable, ByVal nodeTest As String) As XPathNavigator > > Dim xPathNavigator As XPathNavigator = xmlInput.CreateNavigator() > > Dim xPathExpression As XPathExpression = xPathNavigator.Compile(("//" + nodeTest)) > > xPathExpression.AddSort("count(ancestor::node())", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number) > > Dim nodeIterator As XPathNodeIterator = xPathNavigator.Select(xPathExpression) > > If nodeIterator.MoveNext() Then > > Return nodeIterator.Current > > Else > > Return Nothing > > End If > > End Function 'GetDeepestNode > > > > Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator) As String > > Return GetXPath(navigator, "") > > End Function 'GetXPath > > > > Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator, ByVal currentPath As String) As String > > Dim name As String = "" > > Select Case navigator.NodeType > > Case XPathNodeType.Root > > Return "/" + currentPath > > Case XPathNodeType.Element > > name = navigator.Name > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.Comment > > name = "comment()" > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.ProcessingInstruction > > name = "processing-instruction()" > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.Text > > CaseXPathNodeTypeDotText: > > If name = "" Then > > name = "text()" > > End If > > Dim position As Integer = Convert.ToInt32(CDbl(navigator.Evaluate(("count(preceding-sibling::" + name + ")")))) + 1 > > navigator.MoveToParent() > > Dim someString As String > > If currentPath <> "" Then > > 'someString = name & "[" & position & "]" & "/" & currentPath > > someString = name & "/" & currentPath > > Else > > 'someString = name & "[" & position & "]" > > someString = name > > End If > > 'Return GetXPath(navigator, name + "[" + position + "]" +(If currentPath <> "" Then "/" + CurrentPath Else "")) 'ToDo: Unsupported feature: conditional (?) operator. > > Return GetXPath(navigator, someString) > > Case Else > > Return "" > > End Select > > End Function 'GetXPath > > End Class 'Test > > ******************************************* End Code **************************************** > > > Goran Djuranovic > > > "Goran Djuranovic" <djurag@mmcREMOVE_TO_MAIL.org> wrote in message news:%23$jn9lLPGHA.536@TK2MSFTNGP09.phx.gbl... > Hi All, > Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: > > <Root> > <Customer> > <Name>MyName</Name> > </Customer> > </Root> > > I would like to retreive "\Root\Customer\Name" out of it. Something like: > Dim xmlDoc As XMLDocument > Dim strXPath As String = xmlDoc.GetXPath() > > TIA > > Goran Djuranovic Goran,
please don't cross post to multiple groups. Your post is clearly intended for the vb language group; posting it to the C# group only serves to confuse people. Thanks, Peter -- Show quoteHide quoteCo-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com "Goran Djuranovic" wrote: > Here is the solution in VB.NET: > > ************************** Begin Code ******************************* > Imports System.Xml > > Imports System.Xml.XPath > > _ > > Public Class TestXML > > 'Entry point which delegates to C-style main Private Function > > 'Public Overloads Shared Sub Main() > > ' Main(System.Environment.GetCommandLineArgs()) > > 'End Sub > > 'Public Overloads Shared Sub Main(ByVal args() As String) > > ' Dim xmlDocument As New XPathDocument("example.xml") > > ' Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") > > ' If Not (deepestElement Is Nothing) Then > > ' Console.WriteLine("Found element {0}.", deepestElement.Name) > > ' Console.WriteLine(("Path is " + GetXPath(deepestElement))) > > ' End If > > ' Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) > > ' If Not (deepestElement Is Nothing) Then > > ' Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) > > ' Console.WriteLine(("Path is " + GetXPath(deepestNode))) > > ' End If > > 'End Sub 'Main > > Public Sub New() > > End Sub > > Public Sub GetDeepestXPath() > > Dim xmlDocument As New XPathDocument("C:\xmltest.xml") > > Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") > > If Not (deepestElement Is Nothing) Then > > Console.WriteLine("Found element {0}.", deepestElement.Name) > > Console.WriteLine(("Path is " + GetXPath(deepestElement))) > > End If > > Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) > > If Not (deepestElement Is Nothing) Then > > Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) > > Console.WriteLine(("Path is " + GetXPath(deepestNode))) > > End If > > End Sub > > > > Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable) As XPathNavigator > > Return GetDeepestNode(xmlInput, "node()") > > End Function 'GetDeepestNode > > > > Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable, ByVal nodeTest As String) As XPathNavigator > > Dim xPathNavigator As XPathNavigator = xmlInput.CreateNavigator() > > Dim xPathExpression As XPathExpression = xPathNavigator.Compile(("//" + nodeTest)) > > xPathExpression.AddSort("count(ancestor::node())", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number) > > Dim nodeIterator As XPathNodeIterator = xPathNavigator.Select(xPathExpression) > > If nodeIterator.MoveNext() Then > > Return nodeIterator.Current > > Else > > Return Nothing > > End If > > End Function 'GetDeepestNode > > > > Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator) As String > > Return GetXPath(navigator, "") > > End Function 'GetXPath > > > > Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator, ByVal currentPath As String) As String > > Dim name As String = "" > > Select Case navigator.NodeType > > Case XPathNodeType.Root > > Return "/" + currentPath > > Case XPathNodeType.Element > > name = navigator.Name > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.Comment > > name = "comment()" > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.ProcessingInstruction > > name = "processing-instruction()" > > GoTo CaseXPathNodeTypeDotText > > Case XPathNodeType.Text > > CaseXPathNodeTypeDotText: > > If name = "" Then > > name = "text()" > > End If > > Dim position As Integer = Convert.ToInt32(CDbl(navigator.Evaluate(("count(preceding-sibling::" + name + ")")))) + 1 > > navigator.MoveToParent() > > Dim someString As String > > If currentPath <> "" Then > > 'someString = name & "[" & position & "]" & "/" & currentPath > > someString = name & "/" & currentPath > > Else > > 'someString = name & "[" & position & "]" > > someString = name > > End If > > 'Return GetXPath(navigator, name + "[" + position + "]" +(If currentPath <> "" Then "/" + CurrentPath Else "")) 'ToDo: Unsupported feature: conditional (?) operator. > > Return GetXPath(navigator, someString) > > Case Else > > Return "" > > End Select > > End Function 'GetXPath > > End Class 'Test > > ******************************************* End Code **************************************** > > > Goran Djuranovic > > > "Goran Djuranovic" <djurag@mmcREMOVE_TO_MAIL.org> wrote in message news:%23$jn9lLPGHA.536@TK2MSFTNGP09.phx.gbl... > Hi All, > Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: > > <Root> > <Customer> > <Name>MyName</Name> > </Customer> > </Root> > > I would like to retreive "\Root\Customer\Name" out of it. Something like: > Dim xmlDoc As XMLDocument > Dim strXPath As String = xmlDoc.GetXPath() > > TIA > > Goran Djuranovic Solution:
********************** Begin Code *********************** Imports System.Xml Imports System.Xml.XPath Public Class TestXML 'Entry point which delegates to C-style main Private Function 'Public Overloads Shared Sub Main() ' Main(System.Environment.GetCommandLineArgs()) 'End Sub 'Public Overloads Shared Sub Main(ByVal args() As String) ' Dim xmlDocument As New XPathDocument("example.xml") ' Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") ' If Not (deepestElement Is Nothing) Then ' Console.WriteLine("Found element {0}.", deepestElement.Name) ' Console.WriteLine(("Path is " + GetXPath(deepestElement))) ' End If ' Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) ' If Not (deepestElement Is Nothing) Then' Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) ' Console.WriteLine(("Path is " + GetXPath(deepestNode))) ' End If 'End Sub 'Main Public Sub New() End Sub Public Sub GetDeepestXPath() Dim xmlDocument As New XPathDocument("C:\xmltest.xml") Dim deepestElement As XPathNavigator = GetDeepestNode(xmlDocument, "*") If Not (deepestElement Is Nothing) Then Console.WriteLine("Found element {0}.", deepestElement.Name) Console.WriteLine(("Path is " + GetXPath(deepestElement))) End If Dim deepestNode As XPathNavigator = GetDeepestNode(xmlDocument) If Not (deepestElement Is Nothing) Then Console.WriteLine("Found node of type {0}, value {1}.", deepestNode.NodeType, deepestNode.Value) Console.WriteLine(("Path is " + GetXPath(deepestNode))) End If End Sub Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable) As XPathNavigator Return GetDeepestNode(xmlInput, "node()") End Function 'GetDeepestNode Public Overloads Shared Function GetDeepestNode(ByVal xmlInput As IXPathNavigable, ByVal nodeTest As String) As XPathNavigator Dim xPathNavigator As XPathNavigator = xmlInput.CreateNavigator() Dim xPathExpression As XPathExpression = xPathNavigator.Compile(("//" + nodeTest)) xPathExpression.AddSort("count(ancestor::node())", XmlSortOrder.Descending, XmlCaseOrder.None, "", XmlDataType.Number) Dim nodeIterator As XPathNodeIterator = xPathNavigator.Select(xPathExpression) If nodeIterator.MoveNext() Then Return nodeIterator.Current Else Return Nothing End If End Function 'GetDeepestNode Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator) As String Return GetXPath(navigator, "") End Function 'GetXPath Public Overloads Shared Function GetXPath(ByVal navigator As XPathNavigator, ByVal currentPath As String) As String Dim name As String = "" Select Case navigator.NodeType Case XPathNodeType.Root Return "/" + currentPath Case XPathNodeType.Element name = navigator.Name GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Comment name = "comment()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.ProcessingInstruction name = "processing-instruction()" GoTo CaseXPathNodeTypeDotText Case XPathNodeType.Text CaseXPathNodeTypeDotText: If name = "" Then name = "text()" End If Dim position As Integer = Convert.ToInt32(CDbl(navigator.Evaluate(("count(preceding-sibling::" + name + ")")))) + 1 navigator.MoveToParent() Dim someString As String If currentPath <> "" Then 'someString = name & "[" & position & "]" & "/" & currentPath someString = name & "/" & currentPath Else 'someString = name & "[" & position & "]" someString = name End If 'Return GetXPath(navigator, name + "[" + position + "]" +(If currentPath <> "" Then "/" + CurrentPath Else "")) 'ToDo: Unsupported feature: conditional (?) operator. Return GetXPath(navigator, someString) Case Else Return "" End Select End Function 'GetXPath End Class 'Test ************************* End Code ******************************* Goran Djuranovic "Goran Djuranovic" <djurag@mmcREMOVE_TO_MAIL.org> wrote in message news:%23$jn9lLPGHA.536@TK2MSFTNGP09.phx.gbl... Hi All,Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like: Dim xmlDoc As XMLDocument Dim strXPath As String = xmlDoc.GetXPath() TIA Goran Djuranovic
Multiple sdi forms
Programming for USB Modem Check if an object is a type object SOAP Client Avoiding & when adding a JavaScript event handler using Attributes.Add() Converting c# to vb.net Frameworks and Check/Install select query changing bound controls data Threading - Object reference not set to an instance of an object VB.Net and SQL Server Developer |
|||||||||||||||||||||||