[resolved] tExtractXMLField "the root element must be well-formed"

Highlighted
Four Stars

[resolved] tExtractXMLField "the root element must be well-formed"

Hi,
i have a simple XML-File, I read it with tFileInputXML, than one filed I want to extract with tExtractXMLField. The from tFileInputXML mapped variable contains:
<productidentifier>
        <b221>01</b221><b233>VLB_ID_old</b233><b244>3726602</b244></productidentifier><productidentifier>
        <b221>01</b221><b233>Publishers Order No</b233><b244>11199</b244></productidentifier><productidentifier>
        <b221>02</b221><b244>3866324502</b244></productidentifier><productidentifier>
        <b221>03</b221><b244>9783866324503</b244></productidentifier><productidentifier>
        <b221>15</b221><b244>9783866324503</b244></productidentifier>

in tExtractXMLField the Loop Xpath Query is "productidentifier". In this step the error 
Error on line 2 of document  : The markup in the document following the root element must be well-formed. Nested exception: The markup in the document following the root element must be well-formed. - Line: 4
occured.
But the XML-Snippet is wellformed. I'm a little bit helpless.

Accepted Solutions
Four Stars

Re: [resolved] tExtractXMLField "the root element must be well-formed"

The solution is:
<productidentifier>
       <b221>03</b221>
       <b244>9783866324503</b244>
   </productidentifier>

is really " not wellformed". I put an map-Component between the steps, and add an 
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><message release=\"2.1\">" + row2.gtin + "</message>"

so the xml-snippet now is well formed, and the xpath query will work. 
Hope, this helps in other cases too.

All Replies
Four Stars

Re: [resolved] tExtractXMLField "the root element must be well-formed"

The solution is:
<productidentifier>
       <b221>03</b221>
       <b244>9783866324503</b244>
   </productidentifier>

is really " not wellformed". I put an map-Component between the steps, and add an 
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><message release=\"2.1\">" + row2.gtin + "</message>"

so the xml-snippet now is well formed, and the xpath query will work. 
Hope, this helps in other cases too.

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Downloads and Trials

Test drive Talend's enterprise products.

Downloads