One Star

Parsing an XML file with XPath Query

Hi everyone,
I would like to know if in a component like tFileInputXML, we can use a XPath Query like   //something   (for selecting all the element called something in a XML Document) or like   /folder1/something | /folder2/something    (for selecting elements called something in folder1 AND folder2) ???
Sources :  on chapter Selecting Unknown Nodes and Selecting Several Paths
Thanks for your help !
4 REPLIES
Seventeen Stars

Re: Parsing an XML file with XPath Query

hi,
you can use any filter or xpath queries, if you 're using dom4j mode (load entire document in memory).
possible also with textractxmlfield as it switch automaticaly in dom4j mode.
As it load the entire document, JVM need a lot of allocated memories to work with huge xml  Smiley Wink
regards
laurent
One Star

Re: Parsing an XML file with XPath Query

Thnx for your response,
How can I activate this mode ? I'm not sure that I should use it because I have to parse a really fat XML file provided by a webservice (came from an URI)...
The real problem is that I have to pick up a data present in different loop.
Exemple : 
I need to collect all the birthdate of everyone :
--------------------------------------------------------------------------
<Family>
<Father>
<Firstname>Charles</Firstname>
<Birthdate>16/04/1962</Birthdate>
</Father>
<Mother>
<Firstname>Marie</Firstname>
<Birthdate>12/11/1963</Birthdate>
</Mother>
<Children>
<Child>
<Firstname>Nicolas</Firstname>
<Birthdate>22/03/1995</Birthdate>
</Child>
<Child>
<Firstname>Thomas</Firstname>
<Birthdate>01/02/1992</Birthdate>
</Child>
</Children>
</Family>
--------------------------------------------------------------------------
So I would use a XPath Query like //Birthdate or /Father/Birthdate | /Mother/Birthdate but it doesn't seems to work...

My process :
tHttpRequest--tExtractXMLField--tMap--tPostgresOutput
Seventeen Stars

Re: Parsing an XML file with XPath Query

look for mode in advanced setting of component :

tExtractXMLField => dom4j is automatic.
One Star

Re: Parsing an XML file with XPath Query

oh...ok I was using it already...
So why the XPath Queries "//Birthdate" or "/Father/Birthdate | /Mother/Birthdate" doesn't work ?
Is it a bug ? A bad syntax ? Or maybe Talend doesn't works with every kind of XPath Queries ?
Thanks for your answer !
---EDIT---
Source : wwww3schoolscom/xpath/xpath_syntaxasp