469,623 Members | 1,505 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,623 developers. It's quick & easy.

Loading and Persisting XMLDOM

Hello all,

I want to load an in-memory XmlDocument from the server to the client and
create an XMLDOM object using javascript.

I can do it from a url by calling this Javascript from the client.

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.load("url of the persisted file");

I am using .NET and want to fill the XMLDOM directly from an in-memory
XmlDocument object on the server.

As a workaround, I wrapped the .NET Xml control in a div ('divTest') and
called this javascript

var divTest = document.getElementById("divTest");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(divTest.innerHTML);

this worked, but was extremely messy as innerHTML changes all node names to
uppercase -- not really an option.

My gut feeling is that this all very simple but I'm missing something. Is there
a way to read the OutputStream directly into a client-side object or some
such??

Anyone?

TIA

Robert Zurer
Jul 23 '05 #1
3 4069

Since this seems to be IE only, why not use the <xml> element?

<xml id="myxml" src="YOURFILEHERE"></xml> it'll loads all nodes in it,
then use js to access them by its ID.

Danny

On Tue, 28 Jun 2005 17:47:36 -0700, Robert Zurer <ro**********@zurer.com>
wrote:
Hello all,

I want to load an in-memory XmlDocument from the server to the client and
create an XMLDOM object using javascript.

I can do it from a url by calling this Javascript from the client.

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.load("url of the persisted file");

I am using .NET and want to fill the XMLDOM directly from an in-memory
XmlDocument object on the server.

As a workaround, I wrapped the .NET Xml control in a div ('divTest') and
called this javascript

var divTest = document.getElementById("divTest");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.loadXML(divTest.innerHTML);

this worked, but was extremely messy as innerHTML changes all node
names to
uppercase -- not really an option.

My gut feeling is that this all very simple but I'm missing something.
Is there
a way to read the OutputStream directly into a client-side object or some
such??

Anyone?

TIA

Robert Zurer


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2
VK
> I want to load an in-memory XmlDocument from the server to the client
and create an XMLDOM object using javascript.
You may want to use the built-in XML parser for this.
....
<pseudo-code - if IE>
try {
// Newest version for XP SP2 first:
var myDataIsland = new ActiveXObject("Msxml3.DOMDocument");}
catch (e1) {
// Then the older version:
var myDataIsland = new ActiveXObject("Msxml2.DOMDocument");}
}
var myInOutStream = new ActiveXObject("Microsoft.XMLHTTP");
<pseudo-code - read data>
<pseudo-code - if success>
myDataIsland.loadXML(myInOutStream.responseText);
From this point myDataIsland contains perfectly formatted and parsed

XML data.

Jul 23 '05 #3
In article <1120011629.93b3ffd4dcd55a44597afd5239594af9@teran ews>, dann90038
@bluebottle.com says...

Since this seems to be IE only, why not use the <xml> element?

<xml id="myxml" src="YOURFILEHERE"></xml> it'll loads all nodes in it,
then use js to access them by its ID.

Thanks for your response.
This was the idea but it seems that for some reason what ASP.NET XmlControl
does is put the xml on the page but with no enclosing tag that can be found by
javascript. There _is_ no <xml id="myxml" > tag, just the rest of the xml.
Very strange.

I think the intent of this control is to display the result of a transform
which it does very well. In that case it justs spits out the html, also with no
enclosing xml tag.

If I enclose the asp:Xml in a div, and give the div an id, I can access the
xml by the div's innerHTML property but that changes the node names in the xml
to uppercase. Using the div's innerText property only returns data that is
outside a tag so that doesn't work.

Robert Zurer

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Garyrek | last post: by
5 posts views Thread by floods | last post: by
2 posts views Thread by nick.taylor | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.