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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

XML parsing and XML creation with Xpath queries problem

Hai,
i want to read values from input XML and needs to create output XML. i am facing some problems . i put my queries below if any one know please answer me.
InputXML:
<Article>
<Id>rfssee343433534534jdjc</Id>
<Title><!]></Title>
<AdTags>
<AdTag><!]></AdTag>
<AdTag><!]></AdTag>
<AdTag><!]></AdTag>
</AdTags>
<Data>
<Item>
<ItemEntityType>Image</ItemEntityType>
<ItemFilePath>/Image/mgptHFeghebbf.jpg</ItemFilePath>
</Item>
<Item>
<ItemEntityType>Image</ItemEntityType>
<ItemFilePath>/Image/mgptHFeghfrgtd.jpg</ItemFilePath>
</Item>
</Data>
</Article>

My queries:
1.when i read Title using XPATH query : Article/Title
I am getting data without CDATA. how can i get with CDATA.
2. To get AdTag's values i am using below XPATH Queries.
i) Article/AdTags/* --> returns only first AdTag value .
ii) Article/AdTags --> if i select with GetNodes option checked, schema type as object. returns Parent element <AdTags> and child elements.
But i am expecting only child elements with nodes. how can i get this.
3. i need to add new element in ItemId using ItemFilePath value it will be added next to I ItemFilePath element.

eg:
ItemFilePath=/Image/mgptHFeghebbf.jpg
ItemId=mgptHFeghebbf
How can i do this one?

I am using tFileInputXML and tAdvancedOutputXML components as of now.
Labels (3)
17 Replies
Anonymous
Not applicable
Author

Hi
1. Because CDATA indicates Unparsed Character Data. It will be ignored by XML parser.
If you want to get CDATA, select "Get Nodes" option for this column and use tReplace to remove its node.
2. To get all AdTags, the Xpath loop expression should be /Article/AdTags/AdTag.
Fields to Extract
. AdTag
../../Id Id
../../Title Title
3. In your input XML file, there are two loops: AdTag and Item.
So you'd better use two tFileInputXML.
tFileInputXML(loop AdTag)--main-------------------------------------------------------tFileOutputMSXML
tFileInputXML(loop Item)--main----tJavaRow(add ItemId column here)---main---------|
Regards,
Pedro
Anonymous
Not applicable
Author

Hi
You'd better use tFileOutputMSXML instead of tadvancedoutputXML.
Regards,
Pedro
Anonymous
Not applicable
Author

Ok pedro. i will try. thank you.
Anonymous
Not applicable
Author

Hai,
I am trying to merge 2 files but talend not drawing a Main line between ArticleTagParser to MSXML component. please check my job drawing and comment.
Anonymous
Not applicable
Author

Hi,
I think you should be using the tFileInputMSXML component here.
Regards,
Arno
Anonymous
Not applicable
Author

Hai,
tried with tFileInputMSXML instead of tFileInputXML . but i am getting error "talend the schema from the input link is different from the schema defined in the component" .
It's working one of the Log row either AdTag or Data. if i enable both getting error.
the schema from the input link "AdTag\" is different from the schema defined in the component.
i attached screens . please check it.
Anonymous
Not applicable
Author

Hai,
I am trying to Split and merge XML using MSXML. but unable to merge. any one and tell me my job design will work .
job design image attached for reference
Anonymous
Not applicable
Author

Hi
Talend forbids that any loop linking exists in its job.
You'd better use two tFileInputXML with different schemas.
tFileInputXML(loop AdTag)--main-------------------------------------------------------tFileOutputMSXML
tFileInputXML(loop Item)--main----tJavaRow(add ItemId column here)---main---------|
Regards,
Pedro
Anonymous
Not applicable
Author

Hai,
i have to read xml's from a directory . so i am getting loop in tFileInputXML. can u design a job without loop to read files from directory.
I attached my design job for your reference.