Loading and Persisting XMLDOM

Danny (archive)

Usenet Archive
Joined
Feb 18, 2000
Messages
397
Reaction score
0
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
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 ...
 

Robert Zurer

Usenet Archive
Joined
Mar 28, 2002
Messages
26
Reaction score
0
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
 

VK

Usenet Archive
Joined
Apr 16, 2002
Messages
4,741
Reaction score
0
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>
From this point myDataIsland contains perfectly formatted and parsed
XML data.
 

Robert Zurer

Usenet Archive
Joined
Mar 28, 2002
Messages
26
Reaction score
0
dann90038 said:
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
 

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
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top