Practical example of SAX parser

One Star

Practical example of SAX parser

I've found quite some topics on SAX parsing with tInputFileXML, but none really conclusive.
If I set up an XML in my metadata, everything is working fine with DOM parsing, but it won't work with SAX parsing.
SAX and Xpath can be tricky (though there are libraries out there to support Xpath when using SAX parsers), but as that doesn't seem to be supported in Talend, what's the use of offering a SAX parser anyway?
More to the point, how can I properly configure the tInputFileXML component to use SAX parsing, and still give me a result. Is there any proper guideline out there?
One Star

Re: Practical example of SAX parser

Hi
I have tested tFileInputXML with SAX mode and it works fine.
Do you encounter any error? Please show us.
Regards,
Pedro
One Star

Re: Practical example of SAX parser

It's not that I get an error, just that there are no results.
The format of my XML is like this:
<results>
<result>
<binding name="result1">
<literal>Value 1</literal>
</binding>
<binding name="result2">
<literal>Value 2</literal>
</binding>
<binding name="result3">
<literal>Value 3</literal>
</binding>
<binding name="result4">
<literal>Value 4</literal>
</binding>
</result>
</results>

Looping follows this xpath: /results/result
And for retrieving the values, I use xpaths like binding/literal
With DOM it's working fine. For SAX, it does loop over the results, but doesn't extract the actual values. So for an XML file with a 100 <result> tags, I'll get a hundred empty results.
One Star

Re: Practical example of SAX parser

Hi
Modify Loop Xpath query and Xpath query for each columns as the following image.
Then it will work fine with SAX mode.
Regards,
Pedro
One Star

Re: Practical example of SAX parser

Hi pedro,
indeed that's working, though the result is a for each value a 'row', rather than encapsulating the different result1/2/3/4 into a single result 'object'.