How to replace an xml value

Post Reply
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

How to replace an xml value

Post 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...
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: How to replace an xml value

Post 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.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: How to replace an xml value

Post 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 )
{
}
beastridge
Newbie
Posts: 6
Joined: Sun May 27, 2012 7:11 pm

Re: How to replace an xml value

Post 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:"]
apietrocini
Member
Posts: 32
Joined: Fri Mar 24, 2017 7:06 pm
Location: Cleveland, OH

Re: How to replace an xml value

Post by apietrocini »

Thank you!!! Never used the "after" function... That worked perfect!
Post Reply