Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

XML file fetch from http request and parse create new xml and post it

Hai,
I want to do below task using Talend.
Fetch XML files from HTTPRequest and parse it,then create new XML's using fetched XML's and post new XML's to another HTTP request.
I am getting below XML from HTTP request
<Response><Header><Count>1756765</Count></Header><Body>                                    
<Article>
<Id>mggtph12345</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
<Article>
<Id>abdfghtjiaa</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
</Body></Response>

My output XML will be parse Article tag contents as sepearate XML with RootTag Collections
Output XML
Filename:mggtph12345.xml
<Collections>
<Article>
<Id>mggtph12345</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
</Collections>
Filename:abdfghtjiaa.xml
<Collections>
<Article>
<Id>abdfghtjiaa</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
</Collections>

I need to post this each output XML into another HTTP request.
Please provide your help to complete this task.
Labels (3)
5 Replies
Anonymous
Not applicable
Author

Hi,
I think you could use a tFLowToIterate component after fetching the xml from the source. This way you can have an iteration per row, these rows can than have their own xml file.
The tJavaFlex is used to put the data back in a row again.
See the attached screenshot for more info.
Hope this helps.
Regards,
Arno
Anonymous
Not applicable
Author

Hai,
Thanks for ur reply.
I am so new to Talend. i tried with your design but unable to success , i don't know how to configure settings for component. i attached my screens for reference. can u guide me to set correct settings for my xml OR show me your settings screens.
 sample_article.xml
<Response><Header><Count>1756765</Count></Header><Body>
<Article>
<Id>mggtph12345</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
<Article>
<Id>abdfghtjiaa</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
</Article>
</Body></Response>
Anonymous
Not applicable
Author

Hai,
I am using below XPath Queries to parse XML.
LoopXPathQuery:"/Response/Body"
Column XpathQuery
Article "."
Id "Article/Id"
But using this i am getting only values in Article Column. tags are missing.
Output:
mggtph12345
Others
News
ARTICLE

But how can i get with tags.
Need output like:
<Id>mggtph12345</Id>
<Categories>
<Category><!]></Category>
<Category><!]></Category>
</Categories>
<EntityType>ARTICLE</EntityType>
Anonymous
Not applicable
Author

Hi,
You can get it with tags if you check "Get Node" on the richt of your xpath expression.
Regards,
Arno
Anonymous
Not applicable
Author

Thank u . i got nodes.