2

in an XML node that looks like this:

enter image description here

why would this code not work?

                xml = $.parseXML( xml );
                console.log(xml);
                plot = $(xml).find("movie");
                aP = plot.attributes
                console.log(aP);

I am getting undefined for console log. aP

i also tried aP = $(plot).attributes

1 Answer 1

1

attributes is not a jquery property. Try plot.get(0).attributes this way you can use the attributes property on your element and not on a jquery object.

$(xml).find("movie"); //returns jquery object
$(plot) // is a jquery object of a jquery object. You really want your object to be a jquery object aye?

get(index): Description: Retrieve one of the elements matched by the jQuery object.

In other words, your get returns an actual element.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks brotha, you answered a lot in one go

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.