Krystian
Krystian

Reputation: 458

append child node to XML node jquery/js

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.

Upvotes: 1

Views: 1991

Answers (1)

antyrat
antyrat

Reputation: 27765

Use:

$(xml).find('LAYERLIST').eq(0)

Upvotes: 1

Related Questions