Official Content

Obtains flat XML text from the start of an element.

Syntax

&VarBasedOnXmlReader.ReadRawXML()

Type Retruned:
Character

Scope

Extended Data Types: XmlReader
Generators: .NET, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

Description

Allows obtaining flat XML text from the start of an element.

Note: It is valid only for nodes of the Element type.

XML

<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
    <infNFe>
        <cobr>
            <fat>
                <nFat>13111</nFat>
                <vOrig>1731.65</vOrig>
                <vLiq>1731.65</vLiq>
            </fat>
            <dup>
                <nDup>0/</nDup>
                <dVenc>2016-08-08</dVenc>
                <vDup>1731.64</vDup>
            </dup>
            <dup>
                <nDup>0/</nDup>
                <dVenc>2016-08-08</dVenc>
                <vDup>1731.65</vDup>
            </dup>
            <dup>
                <nDup>0/</nDup>
                <dVenc>2016-08-08</dVenc>
                <vDup>1731.66</vDup>
            </dup>
        </cobr>
</NFe>

Code

&XMLReader.OpenFromString(&dadosxml)

// &AuxXML - Varchar
// &SubXml - Varchar
// &XMLReader - XMLReader
// &Sucess - Number

&sucess = &XMLReader.ReadType(NodeType.Element, 'infNFe')
&sucess = &XMLReader.ReadType(NodeType.Element, 'cobr')
&sucess = &XMLReader.ReadType(NodeType.Element, 'dup')

Do While (true)
    &AuxXML = &XMLReader.ReadRawXML()
    If (&AuxXML.Trim().Length() > 0)
        &SubXml.Add(&AuxXML)
    Else
        Exit
    EndIf
EndDo

&XMLReader.Close()

Output:

&SubXml will have 3 items with

Item1

<dup>
    <nDup>0/</nDup>
    <dVenc>2016-08-08</dVenc>
    <vDup>1731.64</vDup>
</dup>

Item2

<dup>
    <nDup>0/</nDup>
    <dVenc>2016-08-08</dVenc>
    <vDup>1731.65</vDup>
</dup>

Item3

<dup>
    <nDup>0/</nDup>
    <dVenc>2016-08-08</dVenc>
    <vDup>1731.66</vDup>
</dup>

Security Tips

This method does not sanitize inputs. Proper sanitization is advised. 

See Also

Read
ReadType
SetDocEncoding.htmXmlReader Data Type





Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant