MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node
Hi.
Why Am I getting
MS.Internal.Xml.Xpath.XpathSelectionIterator
instead of the value of a text node
on this line of code
Code:
Dim encoding As New System.Text.UTF8Encoding(True)
Dim reader As New System.IO.StreamReader(temparray(0).ToString, encoding)
Dim x As XPathDocument = New XPathDocument(reader)
reader.Close() '?
Dim nav As XPathNavigator
nav = x.CreateNavigator()
nav.Evaluate("//*[name()='mcd-Lol'][*[name()='mcd-Number' and text()='1'] and *[name()='mcd-Tamanho' and text()='2']]//*[name()='mcd-Den']/text()")
whereas in this online tester
http://codebeautify.org/Xpath-Tester
it works pwefectly?
The Xml only has text nodes and all with namespaces.
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:mcd="urn:acss:ccf:facturacaoelectronica:schema:xsd:Normalizados">
<ext:UBLExtensions>
<ext:UBLExtension>
<ext:ExtensionVersionID>NormalizadosExtension:1.0</ext:ExtensionVersionID>
<ext:ExtensionContent>
<mcd:NormalizadosExtension>
<mcd:TotalCare>134.49</mcd:TotalCare>
-<mcd:Lol>
<mcd:Number>1</mcd:Number>
<mcd:Tamanho>2</mcd:Tamanho>
<mcd:Area>Z</mcd:Area>
<mcd:TotalCare>124.94</mcd:TotalCare>
-<mcd:Qual>
<mcd:Area>Z</mcd:Area>
<mcd:NumeroQual>1040192667866500</mcd:NumeroQual>
<mcd:Data>2011-11-29</mcd:Data>
-<mcd:Care>
<mcd:NumeroLinha>1</mcd:NumeroLinha>
<mcd:Den>facial</mcd:Den>
<mcd:Quant>1</mcd:Quant>
</mcd:Care>
...
</mcd:Qual>
...
</mcd:Lol>
...
Thanks
Re: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node
Can you provide a sample xml for this issue?
Kgc
Re: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node
Hi.
Just edited the post with the a bit of the xml.
Note that I can't control how the xml is written.
thanks
Re: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node
Well,
Here's a sample that will loop through the XML doc that you provided. This will simply get the mcd:Number node value.
vb.net Code:
'manager is an XmlNamespaceManager object
Dim nodes As XPathNodeIterator = nav.Select("//mcd:NormalizadosExtension/mcd:Lol", manager)
If nodes.MoveNext() Then
Dim node As XPathNavigator = nodes.Current
For Each child As XPathNavigator In node.SelectChildren(XPathNodeType.All)
If child.Name = "mcd:Number" Then
Console.WriteLine("{0}{1}", child.Name, child.Value)
End If
Next
End If
Re: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node
Thanks a lot.
I'll substitute with a case statement to populate a dataset after further digging into grandchildren and greatgrandchildren.
Thanks