How can we read the xml file attributes into sahi script?

138 views
Skip to first unread message

Srini K

unread,
Sep 29, 2014, 5:09:17 AM9/29/14
to sa...@googlegroups.com
Hi,

I have xml file with attributes as shown below. How can we read the xml file attributes into sahi script? I'm using javascript for developing the sahi scripts. Please help me.

xml file:
-----------

<Environment>
<Variable>
<Name>str_LoginURL</Name>
<Value>https://www.gmail.com/</Value>
</Variable>
<Variable>
<Name>UserName</Name>
<Value>John12</Value>
</Variable>

</Environment>

Thanks.

oscar

unread,
Sep 29, 2014, 11:13:08 AM9/29/14
to sa...@googlegroups.com
Hi,

Please follow the following steps.

1. created c:\data.xml. is the XML with the following content:

<data>
<vari>
<nombre>str_LoginURL</nombre>
<valor>http://es.wikipedia.org/</valor>
</vari>
<vari>
<nombre>UserName</nombre>
<valor>Oscar</valor>
</vari>
</data>

2. in sahi/userdata/scripts create the following file: data.sah 

var $xmlStr = _readFile("C:\\data.xml");
_debug($xmlStr);

var $x = new XML($xmlStr);
_debug("-------------");

var $varName1=($x.vari[0].nombre.toString());
var $varValue1=($x.vari[0].valor.toString());
var $varName2=($x.vari[1].nombre.toString());
var $varValue2=($x.vari[1].valor.toString());

_navigateTo($varValue1);
_setValue(_searchbox("search"), $varValue2);


run the data.sah script from the controller




good luck

PS.attached files
PS1. Sorry for my english

Oscar C (Facilos)



--
You received this message because you are subscribed to the Google Groups "sahi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sahi+uns...@googlegroups.com.
To post to this group, send email to sa...@googlegroups.com.
Visit this group at http://groups.google.com/group/sahi.
For more options, visit https://groups.google.com/d/optout.

data.xml
data.sah

Srini K

unread,
Oct 24, 2014, 6:46:25 AM10/24/14
to sa...@googlegroups.com
thanks for ur reply facilos.
Reply all
Reply to author
Forward
0 new messages