18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Read XML Tag value
Hai All,
I have an xml file which contain data like
test.xml
<Book>
<ID>1</ID>
<NAME>ABCD</NAME>
<PRICE>12.23</PRICE>
</Book>
and I need to get the text which is between 'NAME' tag. Please answer ASAP.
_log("Name"+$name);
the $name should get the text 'ABCD'
Eg: Name = ABCD
I have an xml file which contain data like
test.xml
<Book>
<ID>1</ID>
<NAME>ABCD</NAME>
<PRICE>12.23</PRICE>
</Book>
and I need to get the text which is between 'NAME' tag. Please answer ASAP.
_log("Name"+$name);
the $name should get the text 'ABCD'
Eg: Name = ABCD
Answers
This is the answer I found and its working fine... the code is below...
var $XMLStr = _readFile("test.xml");
_set($XMLStr,$XMLStr.toString());
$XMLStr = $XMLStr.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "");
var $x = new XML($XMLStr);
var $value=$x.Book[0].NAME.toString();
_log($value);