One Star

Iterate over node in xml

Hey!
I am trying to retrieve the value of a node in an xml.
Here is a sample of the xml:
<ads>
<ad>
<id>11</id>
<pictures>
<picture>
<picture_url><!]></picture_url>
<picture_title><!]></picture_title>
</picture>
<picture>
<picture_url><!]></picture_url>
<picture_title><!]></picture_title>
</picture>
<picture>
<picture_url><!]></picture_url>
<picture_title><!]></picture_title>
</picture>
</pictures>
</ad>
</ads>
There are more nodes, but basically my biggest problem here is the pictures node because I have to put that in other table.
So what I have to do is loop in the pictures node and get all the pictures and place that in another table
I have tried to use the component tExtractXMLField but when I run the job all I get is this:
Error on line 3 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
Error on line 3 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
Error on line 3 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
I have uploaded an image of the job. There is no data being passed from the tExtractXMLField component.
Here is what I have in the settings:
Loop Xpath Query: "ads/ad/pictures/"
Mapping
id - "../id"
picture_url - "picture/picture_url"
Thanks
4 REPLIES
One Star

Re: Iterate over node in xml

Is the tReplicate producing correct xml structure?
One Star

Re: Iterate over node in xml

Hey! Sorry for the big delay!
The problem is that in the XML output I can't set the Get node checkbox. I either check every node or no node.
One Star

Re: Iterate over node in xml

I think your tReplicate is producing invalid xml. Try outputting it to a file ot tLog.
One Star

Re: Iterate over node in xml

Antonio -
I've also noticed that when the Property Type value of the tFileInputXML component is set to Repository, the Get Nodes checkboxes are all or nothing. (This should probably be opened as a bug in Bug Tracker)
You can get around this by changing the Property Type to Built-In, then you should be able to set Get Nodes one by one. After you have set your Get Nodes value, you can change Property Type back to Repository and it will save your Get Nodes selections.
For your specific Pictures problem, I think the prolog error will be fixed once you select Get Nodes for the Pictures node.
Hope that works...
- Paul