XML generation

P

Peter Laman

The XML DOM implementation extends the XML document object with an
"XML" property to retrieve the textual form of the document. This
causes my javascript code not to work with Firefox, because the XML
DOM standard doesn't have that property. But how else can I get the
XML doc's text?
 
M

Martin Honnen

Peter said:
The XML DOM implementation extends the XML document object with an
"XML" property to retrieve the textual form of the document. This
causes my javascript code not to work with Firefox, because the XML
DOM standard doesn't have that property. But how else can I get the
XML doc's text?

I am not sure I understand what you are asking about. If you use the
xmlNode.xml property with MSXML in IE then the equivalent with Mozilla is
new XMLSerializer().serializeToString(xmlNode)
 
J

Joseph J. Kesselman

Peter said:
But how else can I get the XML doc's text?

Why do you think you need the document's text representation? Why can't
you retrieve the information you need from the DOM?
 
J

Joseph J. Kesselman

I should say that, if you do need to generate XML source (probably not
true in browser code, but may be true in the server or standalone apps):
DOM Level 3 and later has an optional load/save module. If you don't
have that available you may be able to put the DOM through an XSLT
stylesheet or JAXP serializer. Check the documentation for your
environment to see what's available, or load up one of the available
libraries.

But the right place to begin is with the problem you're trying to solve.
If you're working with a DOM in a brower, it would be somewhat unusual
for you to need to see the XML via anything but the browser's "view
source" or by looking at the source file some other way... except
possibly as a debugging aid.
 
P

Peter Laman

I should say that, if you do need to generate XML source (probably not
true in browser code, but may be true in the server or standalone apps):
DOM Level 3 and later has an optional load/save module. If you don't
have that available you may be able to put the DOM through an XSLT
stylesheet or JAXP serializer. Check the documentation for your
environment to see what's available, or load up one of the available
libraries.

But the right place to begin is with the problem you're trying to solve.
If you're working with a DOM in a brower, it would be somewhat unusual
for you to need to see the XML via anything but the browser's "view
source" or by looking at the source file some other way... except
possibly as a debugging aid.

What I'm trying to do is to have the user edit a table's content which
comes from the server in XML format. The scripts parses the XML string
into DOM and manipulates the DOM as the user edits its content. The
aim is to minimize interaction with the server. So all the editing is
done locally using JavaScript. If the user confirms the edits made, I
want to post the changed XML code to the server and for that I want to
generate the XML text from the DOM document.
 
P

Peter Laman

I am not sure I understand what you are asking about. If you use the
xmlNode.xml property with MSXML in IE then the equivalent with Mozilla is
new XMLSerializer().serializeToString(xmlNode)

Thanks Martin, that does the trick!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top