Page 1 of 1

How to replace an xml value

Posted: Wed Feb 21, 2018 4:57 pm
by apietrocini
Using Hp DFE JDF Control... Trying to use asset location as a variable that is buried in the xml... The problem is that the path in the xml reads like this... C:\DEPLOYMENTS\consol.csinc.com\CSIncShare\Output\CS-00001558\0000001_output. I need the value of C: to be changed to an actual ip address... So I decided to try my hand at scripting and used this in the scripting module...

var str = "C:";
var res = str.replace("C:", "123.456.7.8");

and i received an error in switch saying:

Cannot open script package 'C:/Users/switch/Desktop/Test.sscript': neither jobArrived nor timerFired entry point is found

Any help would be greatly appreciated...

Re: How to replace an xml value

Posted: Wed Feb 21, 2018 5:06 pm
by jan_suhr
I think you have to have double slashes before the IP-number, and then they might need to be escaped as well meaning //// before the IP-number.

Re: How to replace an xml value

Posted: Wed Feb 21, 2018 5:17 pm
by cstevens
It also looks like your script doesn't have a proper entry point function. It should be wrapped like this:

Code: Select all

function jobArrived( s : Switch, job : Job )
{
}
or if using a timer this:

Code: Select all

function timerFired( s : Switch )
{
}

Re: How to replace an xml value

Posted: Tue Feb 27, 2018 3:19 am
by beastridge
you can do this without scripting... using single line text with variables. Use "After" C: and in the front place your ip address. Like this example.

\\ip address\[Metadata.Text:Path="/mDocEnvelope/Order/DocumentHeader/FilePath",Dataset="Xml",Model="XML",After="C:"]

Re: How to replace an xml value

Posted: Fri Mar 02, 2018 10:13 pm
by apietrocini
Thank you!!! Never used the "after" function... That worked perfect!