Access XML metadata

Post Reply
mresong
Newbie
Posts: 1
Joined: Mon Mar 18, 2013 9:17 pm

Access XML metadata

Post by mresong »

Enfocus Community -



I am writing a script to assist in sorting a PDF that has had XML metadata added via the XML pickup flow element.



In the javascript I am creating I reference the dataset as:



var xml = job.getDataset( "Xml" );



However when I try to access the dataset via:



var itemNode = xml.evalToNode(nodexpath);



I get an error message stating "TypeError. evalToNode undefined or not a function".



I can also note that autocomplete in the script editor did not seem to find evalToNode as valid either however it is an xml data structure being added as metadata.



Is there a way to work around this?



To be complete in the data I am providing, I have an XML such as:





1234.pdf

2





4321.pdf

1







And I have both PDFs (assets) and I need to be able to sort by the data relative to the filename node. This is all one "job", which I have split into separate jobs each with their own copy of the XML, then taken those seperate jobs and used "XML pickup" against them. Now, I just need to be able to get the appropriate elements (relative to the particular filename) to use to sort the asset for the now split job(s) (which can each be independent of each-other without issue).



If anyone has an idea for a better way to do this - I'm all ears.. I did try a condition, but I cannot get the XPATH filter ( the [filename=this] ) to correctly filter based upon the filename or the job name. If you know something to replace the "this" with on the XPATH filter, that can save me doing any javascript funkyness.



Thank you in advance - all ideas are appreciated!



Matt
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Access XML metadata

Post by tz8 »

mresong wrote: Enfocus Community -

var xml = job.getDataset( "Xml" );


nearly right!



the correct way to access the metadata is:



var jobDataset = job.getDataset( "Xml" );

var jobXML = new Document ( jobDataset.getPath() );



you can then use



var foo = jobXML.evalToNode( "xpath expression");



to get the data you want.



Cheers,



Thorsten
MattR
Newbie
Posts: 1
Joined: Tue Mar 19, 2013 4:10 am

Access XML metadata

Post by MattR »

tz8 wrote:

var jobXML = new Document ( jobDataset.getPath() );




This little gem did it for me.. Thank you very much!!



Matt
Post Reply