Get Attribute Value From Simple XML Using JQuery / Javascript
jquery, xml
Solution
Try
var string = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ParentNode Symbol="$"><Row book = "test" price ="80"/></ParentNode>';
var $doc = $.parseXML(string);
console.log($($doc).find('ParentNode').attr('Symbol'))
Demo: Fiddle
Problem
I tring to get the attribute value from the following simple xml using my javascript. XML : ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?><ParentNode Symbol="$"><Row book = "test" price ="80"/></ParentNode> ``` jQuery: `$('ParentNode').attr('Symbol');` The JQuery is working fine if the xml code is ``` <ParentNode Symbol="$"><Row book = "test" price ="80"/> </ParentNode> ```