/    Sign up×
Community /Pin to ProfileBookmark

Get a tag’s property in responseXML?

It’s the first time I’m playing with xmlhttp.responseXML… I’ve only been using responseText until now…

I have one question, let’s say I have this XML file:

[code]
<?xml version=’1.0′ encoding=’ISO-8859-1′?>
<test>
<element parameter=”value”>content</element>
</test>
[/code]

Is there any way to know that “parameter” is equal to “value” in js? I’ve tried xmlDoc.getElementsByTagName(‘element’)[0].parameter but that doesn’t seem to work. Is this achievable?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzAug 26.2007 — What mime-type did you send the XML file with?
Copy linkTweet thisAlerts:
@ZnupiauthorAug 26.2007 — I just saved an .xml file, it's not created dynamically by PHP or whatever, I was just testing. The Content-Type header is application/xml. Should it be text/xml? I do get "content" if I xmlDoc.getElementsByTagName('element')[0].childNodes[0].nodeValue so I don't think this is a problem.
Copy linkTweet thisAlerts:
@KravvitzAug 26.2007 — application/xml is good.

Try this:
xmlDoc.getElementsByTagName('element')[0].getAttribute('parameter')
Copy linkTweet thisAlerts:
@ZnupiauthorAug 26.2007 — Thanks that worked ?
×

Success!

Help @Znupi 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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