• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

xml and javascript

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to create an xml object using javascript. like create node attributes etc and send it through ajax. i need to know about the xml manipulation methods and objects in javascript. can anyone help me in this
 
Author
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To manipulate XML in JavaScript you have to deal with the different instantiation methods in XML.

To create an XML document in IE:

var xmlDoc = new ActiveXObject( "Microsoft.XmlDom");

To load something in the document you can load it by referencing the file
xmlDoc.load( URL), or
xmlDoc.load( str) where str is a valid XML document.

The result is an XML DOM document that can be manipulating like the XML DOM.

In Mozilla you need the following line
var xmlDoc = document.implementation.createDocument( namespace, rootElement, null);

The result is an XML document with namespace, and rootElement that can be manipulated using the standard XML DOM methods.

For exact details of the methods I would reference the XML DOM documentation.

Then to save the XML to a string, for IE you use the xml property associated with a node, and for Mozilla you use the XMLSerializer object.

Christian
[ February 24, 2006: Message edited by: Christian Gross ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic