why i can't get the value from XML

Post Reply
nicktazo
Newbie
Posts: 13
Joined: Sat Apr 13, 2013 5:31 pm

why i can't get the value from XML

Post 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






carineb
Member
Posts: 31
Joined: Wed Oct 20, 2010 2:39 pm

why i can't get the value from XML

Post 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
nicktazo
Newbie
Posts: 13
Joined: Sat Apr 13, 2013 5:31 pm

why i can't get the value from XML

Post 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
caio
Newbie
Posts: 13
Joined: Tue Mar 22, 2011 8:27 am

why i can't get the value from XML

Post by caio »

You can ceck the variable value:



job.log(1, 'value=' + myvariable)
nicktazo
Newbie
Posts: 13
Joined: Sat Apr 13, 2013 5:31 pm

why i can't get the value from XML

Post by nicktazo »

Real appreciate! works!



Thanks much



Nick



caio wrote: You can ceck the variable value:



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