Xpath expression not working in Workflow xmlget

Trying to select the L00100 node HAVING the attribute Code so I can use the value of Code. This works fine in an online xpath tester

but it does not work in workflow

Watch.expandstring(“xmlget(‘/Root[1]/L00100[@Code]/@Code’,Value,KeepCase,NoTrim)”)

xml:

<?xml version="1.0" encoding="UTF-8"?> 28942 V.L. Grit 80001 2004 VT0124505 00011 239 Ja 00002 mail@vr.nl 7000 AA SUMIR De heer V.L. Grit Rienogsrt 24 7000 AA DLSE 28942 80001 2 augustus 2023 VTA5659 Geachte heer Grit, 2 augustus 2023

Please provide some valid xml code. To format it properly here, copy and paste it in the comment editor, then select it and click the </> tool bar button. In the end it should look something like this:

<?xml version="1.0"?>
<root>
	<ID>49656775</ID>
	<LastName>Doe</LastName>
	<FirstName>John</FirstName>
	<Address1>1121, 59th Avenue</Address1>
	<Address2>Bldg 11</Address2>
	<City>Oceanside</City>
	<State>CA</State>
	<Country>US</Country>
	<ZipCode>21191-3301</ZipCode>
	<Email>doej@emailserver.com</Email>
</root>
<?xml version="1.0" encoding="UTF-8"?>
<Root>
	<L00001>28942</L00001>
	<L99902>V.L. Grit</L99902>
	<L60000>80001</L60000>
	<L10131>2004</L10131>
	<L10004>VT0124505</L10004>
	<L00100 Code="00011" Omsch="V"/>
	<L98043/>
	<L99823>239</L99823>
	<L00006 Code="00001" Omsch="Geachte heer Grit,"/>
	<L09303>Ja</L09303>
	<L09991>00002</L09991>
	<L02402>mail@vr.nl</L02402>
	<L99052/>
	<L00011>7000 AA</L00011>
	<L97103>SUMI</L97103>
	<L09071 Code="VET" Omsch="Het V Team"/>
	<L10015 Code="VET" Omsch="Het V Team"/>
	<L97420/>
	<L03059/>
	<L90000/>
	<L99907>De heer</L99907>
	<L99902>V.L. Grit</L99902>
	<L99903>Rienogsrt 24</L99903>
	<L99904>7000 AA  DLSE</L99904>
	<L00001>28942</L00001>
	<L10000>80001</L10000>
	<L97020>2 augustus 2023</L97020>
	<L60004>VTA5659</L60004>
	<L99906>Geachte heer Grit,</L99906>
	<L97022>2 augustus 2023</L97022>
</Root>

So if I understand your original post correctly, you want to select all nodes that are named L00100 and that have a Code attribute (which, in the data you provided, would find a single node with Code=00011).

I don’t believe this is possible with xmlGet(), which cannot select by attribute. One way to get around this is to use a script with XMLDOM:

var xmldoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
xmldoc.async = false;
xmldoc.load(Watch.GetJobFileName());

var nodes = xmldoc.selectNodes('/Root/L00100[@Code]/@Code');
for (var i=0; i < nodes.length; i++) {
  Watch.Log("Result "+(i+1)+" = "+nodes.item(i).text,2);
}

This returns a collection of nodes that match the query criteria.

If you know for sure that there can only be a single target node, you can instead use

var node = xmldoc.selectSingleNode('/Root/L00100[@Code]/@Code');
Watch.Log("Result = "+node.text,2);

Clear! Will give your solution a try. Thx for your support :white_check_mark: