XML DOM Javascript

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2008 08:36 PM
Hi All,
I am trying to access a avm node which is a xml document and I want to get the contents of the xml in JavaScript like I can do with document.xmlNodeModel in .ftl files. I was wondering if I can do it in javascript as well. I looked at contents in the avm node it did not show the xmlNodeModel reference for that avm node.
Thanks
I am trying to access a avm node which is a xml document and I want to get the contents of the xml in JavaScript like I can do with document.xmlNodeModel in .ftl files. I was wondering if I can do it in javascript as well. I looked at contents in the avm node it did not show the xmlNodeModel reference for that avm node.
Thanks

Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2008 04:30 AM
If you can grab the content of the node then yes, you can process it as XML in JavaScript; Rhino 1.6 and later has built-in support for E4X. For example, you can do something like this in your JavaScript:
rocessing_XML_with_E4X
var xml = new XML('<your XML string>');
Here's a link to a basic tutorial if you are not familiar with E4X: http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2008 10:44 AM
Thanks for the response but in the xml to get xml in javascript
<?xml version="1.0" encoding="UTF-8"?> this line posses an error.
Right now I am manipulating the string with javascript code.
how to get rid of this line.
Thanks.
<?xml version="1.0" encoding="UTF-8"?> this line posses an error.
Right now I am manipulating the string with javascript code.
how to get rid of this line.
Thanks.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2008 11:17 AM
The simplest way is to use substring:
var xmlstr = '<your xml string>';var header = '<?xml version="1.0" encoding="UTF-8"?>';xmlstr = xmlstr.substring(header.length);var xml = new XML(xmlstr);

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2008 11:20 AM
Thanks

