Talend tExtractXMLField

I have this work in Talend that needs to extract a field and scroll it.

My big problem is that the code loops through the XML fields but returns null. Here is an example XML:

<?xml version="1.0" encoding="ISO-8859-1"?>
<empresas>
    <empresa>
        <imoveis>
            <imovel>
                [-- some fields --  ]

                <fotos>
                    <nome id="" order="">photo1</nome>
                    <nome id="" order=""></nome>
                    <nome id="" order=""></nome>
                    <nome id="" order=""></nome>
                </fotos>
            </imovel>
            [ -- other entries here -- ]
        </imoveis>
    </empresa>
</empresas>

Now, using the tExtractXMLField component, I'm trying to get the "fotos" element. Here is what I have in the component: enter image description here

I tried to modify the XPath request and the XPath loop request, but as a result I either do not go through this field or get zero in the value field in tMap.

Here is the image of the assignment:

enter image description here

You can see that I got 4 elements from XML, but what I get is null in the "nome" field. There should be something wrong with XPath, but I cannot find the problem :(

Hope someone can help me. thanks Notes: I am using talendv4.1.2 on ubuntu 10.10 64bit

+3
5

<nome>, Loop XPath

"/empresas/empresa/imoveis/imovel/fotos/nome"

foto_nome XPath -

"text()"

: XML, (</imoveis> "s" ).

+7

. - XMLinput , .

- , . XMLinput , Loop XPath "/empresas/empresa/imoveis/imovel/fotos" fotos Get Nodes. XPath fotos "../fotos" ".".

extractXMLField . , , tSetGlobalVar , , fotos, .

+1

sample talend job
, . , "" "fotos".

+1

xpath "empresas". , "? Xml version =" 1.0 "encoding =" ISO-8859-1 "?" , .

, ​​ tFileInputXML.

0

, XML XML XML.

XML: XML, , , tFileInputXML, tExtractXMLField, tFileInputXML :

  • xpath <nome>, , "//nome"
  • 3 , tFileInputXML
  • xpath "."
  • id xpath "@id"
  • xpath "@order"

XML XML: tExtractXMLField: XML-, XML, .

, tExtractXMLField , XML. : xml, :

<arg2> 
  <![CDATA[
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <exportInscriptionEnLigneType>
      <date>2015-04-10</date>
      <nbDossiers>2</nbDossiers>
      <reference>20150410100</reference>
      <listeDossiers>
        <dossier>
          <numOrdre>1</numOrdre>
          <identifiantDossier>AAAAA</identifiantDossier>
        </dossier>
        <dossier>
          <numOrdre>2</numOrdre>
          <identifiantDossier>BBBBB</identifiantDossier>
        </dossier>
      </listeDossiers>
    </exportInscriptionEnLigneType>
]]>
</arg2> 

XML arg2 > XML-, .

tExtractXMLField is created for this purpose. I wrote a tutorial on how to achieve this work, please see how to extract xml from xml here . This is in French, but screenshots may help to understand a few comments provided.

Hope this helps.

Yours faithfully,

0
source

Source: https://habr.com/ru/post/1791964/


All Articles