0

I have an XML file of this Kind :

<data>
 <First id="FirstOne">
  <lines id="Lines">
   <Second id= "second" ColorPerVertex='true'></Second>
   <third id="third" color ='true'></third>
  </lines>
 </First>
</data>

I was trying to copy all the childnodes of the parentnode - lines.

this is the kind of snippet I tried :

var txt=$(xml).find("lines").children();
alert(txt); // to check if it is really does fetch it. 

it does not output all the children including the attributes of it.

I tried looking into this example here. Even this did not work for me.

is there any way in which I can do it?

Community
  • 1
  • 1
user1306229
  • 51
  • 1
  • 7

1 Answers1

0

From the docs:


jQuery( html [, ownerDocument] )

html: A string of HTML to create on the fly. Note that this parses HTML, not XML.


Use $.parseXML instead to create the XML-document.

var txt=$($.parseXML(xml)).find("lines").children();
Dr.Molle
  • 116,463
  • 16
  • 195
  • 201