If you use XML::LibXML::Reader in perl, you can analyze XML by retrieving nodes from the top, but what should you do with javascript (or jQuery, etc.Or is there a library that can do the same thing?
javascript xml
There used to be an E4X.Deprecated now
Instead, it would be good to use DOMParser
Note:
Sample Code
const xml=`<sales vendor="John">
<item type="peas" price="4" quality="6"/>
<item type="carrot" price="3" quality="10"/>
<item type="chips" price="5"quantity="3"/>
</sales>`;
const parser = new DOMParser();
const sales=parser.parseFromString(xml, 'text/xml');
conditions = Array.from(sales.getElementsByTagName("item"));
alert(items.find(item=>item.getAttribute("type")==="carrot").getAttribute("quantity"));
alert(sales.getElementsByTagName("sales").item(0).getAttribute("vendor"));
items.forEach(item=>alert(item.getAttribute("price"))))
© 2024 OneMinuteCode. All rights reserved.