question

SurajRevankar avatar image
0 Votes"
SurajRevankar asked ·

How to fetch xml attribute value in liquid template - XML to JSON Liquid


Hi,

I am trying to fetch the xml attribute value using liquid template. Examples are as below.

XML example:

     <ns0:root xmlns:ns0="http://customnamespace.com" xmlns:ns1="http://customnamespace2.com">
   <ns1:product>
   <ns1:name QualifierID="std.lang.all" >TV</ns1:name>
   <ns1:price>499.9</ns1:price>
  </ns1:product>
  </ns0:root>

Liquid Template used:

 {
 "name": "{
                 {content.product.name['QualifierID']}}",
 "price": "{
                 {content.product.price}}",
 }

Output expecting :

   {
 "name": "std.lang.all",
 "price": "499.9"
 }

I tried couple of ways but not able to fetch the xml attribute value. it gives me empty value for name.

Best regards,
Suraj





azure-logic-appsazure-maps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

TarunGarg-3625 avatar image
0 Votes"
TarunGarg-3625 answered ·

I tried few options but nothing seems to work. One other approach is convert this XML to JSON and then use liquid map

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Yep, by parsing into JSON i can extract it , but from XML attributes couldn't find a way.

0 Votes 0 · ·