/    Sign up×
Community /Pin to ProfileBookmark

Javascript loaded XML failing due to doctype

I have an XML file that I’m trying to load into and xml object, however the doctype tag is killing the javascript, and does not parse the XML at all.

If I remove the doctype, the javascript can parse, and I can access the XML DOM. So I know the XML is valid. Even with the Doctype, it validates. However Javascript does not like it.

I don’t have a choice to remove the Doctype tag of the XML. Does anyone have a solution to this?

If I remove the Doctype, this method works to parse the XML DOM:

[CODE]xmlDoc = new ActiveXObject(“Microsoft.XMLDOM”);
xmlDoc.async = false;
xmlDoc.load(filename);[/CODE]

Also, if I use the .open method to retrieve the XML, i cannot access the XML DOM via xmlhttp.responseXML. But I do get a result when I use xmlhttp.responseText, it displays the corresponding XML.

[CODE]xmlhttp.open(“GET”, filename, false);
[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meAug 30.2011 — just split() with the doctype string and join() with "" and you'll have the text without the doctype. for true responseXML docs you need to serve valid xml, without any doctype.
×

Success!

Help @p_phresh spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...