Page 1 of 1

why i can't get the value from XML

Posted: Sat Apr 13, 2013 5:56 pm
by nicktazo
Dears



here is my xml sample



8

4





i am trying to use the below scripts expression to get data



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

var ups =jobDataset.getPath("/data/upsnumber");

var copies=jobDataset.getPath("/data/copynumber");



but always show me error message



No matching slot found, available overloads are: QString DatasetXML::getPath()



Real appreciate anyone can help me to solve this problem.



Thanks



Nick







why i can't get the value from XML

Posted: Mon Apr 15, 2013 11:03 am
by carineb
Hi Nick,



here is a script expression that will give you the value from your XML sample:



var theCopynumber = job.getVariableAsString('[Metadata.Text:Path="/data/copynumber",Dataset="Xml",Model=XML]')





In this example you'll get the valua as string, you can also use getVariableAsNumber, getVariableAsBoolean or getVariableAsDate, depending on your needs.



Hope this helps?

Carine

why i can't get the value from XML

Posted: Mon Apr 15, 2013 2:33 pm
by nicktazo
Thanks much! it works.



but i found i get a wrong value perhaps. i am trying to check it with 'alert' function. but it seems it is not supported. how can i check the procedure variables like debug.print?



Thanks again



Nick







carineb wrote: Hi Nick,



here is a script expression that will give you the value from your XML sample:



var theCopynumber = job.getVariableAsString('[Metadata.Text:Path="/data/copynumber",Dataset="Xml",Model=XML]')





In this example you'll get the valua as string, you can also use getVariableAsNumber, getVariableAsBoolean or getVariableAsDate, depending on your needs.



Hope this helps?

Carine

why i can't get the value from XML

Posted: Mon Apr 15, 2013 6:18 pm
by caio
You can ceck the variable value:



job.log(1, 'value=' + myvariable)

why i can't get the value from XML

Posted: Mon Apr 15, 2013 6:26 pm
by nicktazo
Real appreciate! works!



Thanks much



Nick



caio wrote: You can ceck the variable value:



job.log(1, 'value=' + myvariable)