473,327 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

XML trouble in IE

I'm having trouble with XML in IE.
I wrote the following function and it works fine in Firefox, but when I
try to run it in IE, I get the error "getElementsByTagName(..).0' is
null or not an object." at the line var
orgList=window.document.getElementsByTagName("xml" )"
The xml is embedded into the page and bracketed by <div><xml> and
</xml></div> tags and, as I said, it is working fine in Firefox.

function loadOrgOptions() {
var orgList =
window.document.getElementsByTagName("xml")[0].getElementsByTagName("orglist")[0].getElementsByTagName("office");
document.frmSubmission.ddOffice.options.length = 0;
document.frmSubmission.ddOffice.options[0] = new Option ("Please
select", "0", true, true);
for (var i = 0; i < orgList.length; i++) {
var xmlThisOrg = orgList[i];
var strValue =
xmlThisOrg.getElementsByTagName("officeIdent")[0].firstChild.data;
var strText =
xmlThisOrg.getElementsByTagName("officeName")[0].firstChild.data;
document.frmSubmission.ddOffice.options[i+1] = new Option (strText,
strValue, false, false);
}
}

Apr 14 '06 #1
3 1722


br**********@wpafb.af.mil wrote:

The xml is embedded into the page and bracketed by <div><xml> and
</xml></div> tags and, as I said, it is working fine in Firefox.
Since when can you put XML into HTML? You are trying something that goes
against the defined usage of HTML it seems.
On the other hand IE/Win knows an extension to HTML, so called XML data
islands which can be embedded in a HTML document. To allow that the
known HTML elements are extended by an xml element which is supposed to
contain an XML document (or reference one in an external file). That way
however the XML inside of the xml element is parsed by MSXML, an XML
parser, and the XML DOM that parser builds is exposed as the XMLDocument
property of the xml element in the HTML DOM.
So for IE/Win and its XML data island mechanism you could use e.g.
var xmlIsland = document.getElementsByTagName('xml')[0];
if (xmlIsland && typeof xmlIsland.XMLDocument != 'undefined') {
var orgList = xmlIsland.XMLDocument.getElementsByTagName('orglis t')[0];

But as said, that embedding mechanism is IE/Win specific, with other
browsers what you regard as XML is seen by the text/html tag soup
parsers as unknown elements and trying to deal with that will not be
very portable. Consider putting the XML data in an XML file of its own
and then use XMLHttpRequest to load the XML data, that has better cross
browser support and that way an XML parser is used to parse the XML.

function loadOrgOptions() {
var orgList =
window.document.getElementsByTagName("xml")[0].getElementsByTagName("orglist")[0].getElementsByTagName("office");
document.frmSubmission.ddOffice.options.length = 0;
document.frmSubmission.ddOffice.options[0] = new Option ("Please
select", "0", true, true);
for (var i = 0; i < orgList.length; i++) {
var xmlThisOrg = orgList[i];
var strValue =
xmlThisOrg.getElementsByTagName("officeIdent")[0].firstChild.data;
var strText =
xmlThisOrg.getElementsByTagName("officeName")[0].firstChild.data;
document.frmSubmission.ddOffice.options[i+1] = new Option (strText,
strValue, false, false);
}
}


--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 14 '06 #2
Unfortunately Active X is turned off in this environment. Since
XMLHttpRequest is built into Active X, that means that XmlHttpRequest
won't work in this environment. Believe me when I say that I wish it
were otherwise.
"Since when can you put XML into HTML?" I didn't think it would work,
but Firefox can read it. IE can't.

Apr 14 '06 #3


br**********@wpafb.af.mil wrote:
"Since when can you put XML into HTML?" I didn't think it would work,
but Firefox can read it. IE can't.


I have explained in some detail that IE _does_ support an extension to
HTML, so called XML data islands, to embed XML in a HTML document. So IE
_can_ do it and will allow you to access the XML DOM in an XML data island:
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/xml.asp>

Firefox on the other hand will use its HTML parser on the complete HTML
document so it _does not_ support parsing of XML embedded in HTML. With
Firefox the proper way is to move to XHTML and embed the XML as XML data
in a different namespace, making sure the whole document is parsed as
XML and not HTML. Then the XML parser will certainly parse according to
XML rules.

See
<http://home.arcor.de/martin.honnen/javascript/2006/04/test2006041401.html>
as an example, just because you put an xml element into a HTML document
does not mean that Firefox parses anything to XML rules, rather it
parses everything as HTML tag soup and what you regard as XML is not
checked against well-formedness errors (as in the first xml element) and
does not result in a (in terms of XML) properly nested DOM tree (as in
the second xml element where

<gods>
<god name="Kibo" />
<god name="Xibo" />
</gods>

leads to a tree of

gods
--- god
--- god

as that is what the HTML tag soup parser makes of that markup)

IE/Win on the other hand with its XML data island extension to HTML uses
MSXML to parse the contents of the xml elements according to XML rules
and thus finds the well-formedness violations in the first xml element
and properly builds the XML DOM tree in the second xml element.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James | last post by:
Hi I am having some trouble getting a asp page to load. Im a noob to the asp side. I have followed knowledege base Article 301305. I am running 2000 adv, IIS 5.0 I have the following...
4
by: Jacek Dziedzic | last post by:
Hi! First of all, I hope my problem is not too loosely tied to the "standard C++" that is the topic of this group. I have some code that exhibits a strange behaviour: on one computer, where I...
0
by: Paul C | last post by:
Hello, everybody. I am having trouble running some of the VS.NET samples, specifically the CarSelector web app, which is very simple. The symptom is that the web controls (drop down listboxes and...
0
by: Alexandre Jaquet | last post by:
Hi does anybody know how to solve my trouble, when I try to create a MS Office project I always got trouble. I can't create office project when I try to create one vs.net restart ... :s
2
by: Jeff | last post by:
/* -------------------------------------------------------------------------- Hello, I was experimenting with class templates and specializing member functions and came across a simple problem...
1
by: Jim Bancroft | last post by:
Hi everyone, I'm running into a problem with my ASP.Net application. I've just created a new aspx page which uses some new components of mine that inherit from ServicedComponent and are...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
2
by: JLupear | last post by:
I am having trouble with my code again, I had prepared a question and the code to upload, however I am having trouble posting it, are there limits to the amount of lines you can post? I split it...
0
by: mrchatgroup | last post by:
news from http://www.mrchat.net/myblog/myblog/small-accidents-mean-big-trouble-for-supercollider.html Small Accidents Mean Big Trouble for Supercollider Image Scientists expect startup...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.