1

I've got XML like this:

<REQUEST> 
  <GET_IMAGE> 
   <PROPERTIES>
     <LAYERLIST>
     </LAYERLIST> 
    </PROPERTIES>
   </GET_IMAGE>
</REQUEST>

and I wanna to add to node LAYERLIST few other child nodes like this:

<LAYER id="1"/>
<LAYER id="2"/>
.
.
.

I'm trying to do this by

$(xml).find('LAYERLIST').get(0).append(nodes)

and when I'm doin just $(xml).find('LAYERLIST').get(0) I can get to this node, but when I'm doing $(xml).find('LAYERLIST').get(0).append(nodes) I get 'append is not a function'. I tried with appentTo to and effect were pretty much same.

1
  • .get() returns a DOM element, not a jQuery object: api.jquery.com/get. Just remove it or use appendChild (that of course also depends on what nodes is) or use .eq instead: api.jquery.com/eq Commented Apr 24, 2012 at 14:54

1 Answer 1

1

Use:

$(xml).find('LAYERLIST').eq(0)
Sign up to request clarification or add additional context in comments.

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.