PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node-VBForums
Results 1 to 5 of 5

Thread: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    24

    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
    Last edited by mehrlicht; Sep 5th, 2016 at 04:49 AM. Reason: xml code

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,946

    Re: MS.Internal.Xml.Xpath.XpathSelectionIterator instead of value of text node

    Can you provide a sample xml for this issue?

    Kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    24

    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

  4. #4
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,946

    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:
    1. 'manager is an XmlNamespaceManager object
    2. Dim nodes As XPathNodeIterator = nav.Select("//mcd:NormalizadosExtension/mcd:Lol", manager)
    3.         If nodes.MoveNext() Then
    4.             Dim node As XPathNavigator = nodes.Current
    5.             For Each child As XPathNavigator In node.SelectChildren(XPathNodeType.All)
    6.                 If child.Name = "mcd:Number" Then
    7.                     Console.WriteLine("{0}{1}", child.Name, child.Value)
    8.                 End If
    9.             Next
    10. End If
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2013
    Posts
    24

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width