xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "lakshmikant panchal" <lakshmikan...@rediffmail.com>
Subject Loading XML document as a string from Javascript variable
Date Tue, 22 Oct 2002 13:10:04 GMT
I am trying to load XML document in the browser from a JavaScript 
variable. The
reason is when I create XML document from a Database I don't want 
to store it
on a disk and then load from a disk, I just want to pass it to a 
browser as a
string/variable.

Well, I know how to do it in IE: by using xmlDoc.loadXML method 
like in example
below

var xmlStr = "<CAT><CD><TITLE>Empire</TITLE><ARTIST>Bob
Dylan</ARTIST></CD><CD><TITLE>Hide</TITLE><ARTIST>Bonnie</ARTIST></CD></CAT>";
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.onreadystatechange = tmp;
xmlDoc.loadXML(xmlStr);

function tmp()
{
if (xmlDoc.readyState == 4) generateFromXML();
}

function generateFromXML()
{
// processing code
// ...
}

In Netscape 6 I use:

var xmlStr = "<CAT><CD><TITLE>Empire</TITLE><ARTIST>Bob
Dylan</ARTIST></CD><CD><TITLE>Hide</TITLE><ARTIST>Bonnie</ARTIST></CD></CAT>";
xmlDoc = document.implementation.createDocument("", "", null);
xmlDoc.onload = generateFromXML;
xmlDoc.loadXML(xmlStr);

function generateFromXML()
{
// processing code
// ...
}

Well, xmlDoc.loadXML(xmlStr) doesn't work.

Does anybody know how to do the same thing in Netscape 6?




---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message