0

This is my exact xml file:

<?xml version="1.0" ?>
<blah_de_blah>          
    <unblocker_details  table_color="#F2F0FF" type="zip" alt_link="http://g.org/288"
 link_for_deletion="3-QQ5DJoa-AWFT7a9" comment="zippy"  />


    <unblocker_details  table_color="#FFFFFF" type="Webpage" alt_link="http://www.gg.com"
 link_for_deletion="4-rOX2brr-2qQeGY3" comment="test"  />

</blah_de_blah>

I have successfully gotten it via an ajax request, then did this:

var xmlDoc=null;
    var parser = new DOMParser();
    xmlDoc = parser.parseFromString(data, "text/xml");

and now I need to get each of those values from unblocker_details into a variable:

for example:
the_table_color=table_color;
the_type =type;
etc

Please also check if I declared the xml properly as I am very new to this.

Thanks!

2 Answers 2

3

Something like this:

var nodes = xmlDoc.getElementsByTagName("unblocker_details");  

for(i=0; i< nodes.length; i++) {
   the_table_color = nodes[i].getAttribute("table_color");
   // get other attributes the same way
}
Sign up to request clarification or add additional context in comments.

1 Comment

Hours and hours of frustration to finally get it to work... its been one of "those" days. Wish I could upvote this 100 times!
1

You can use this http://www.w3schools.com/ajax/ajax_xmlfile.asp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.