Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
XML Data by Name instead of childNode Array?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Martin Honnen, post: 4936374"] If you know the structure of the XML exactly then all you need is e.g. var root = xmlDoc.documentElement; var result = root.getElementsByTagName('RESULT')[0]; var security = root.getElementsByTagName('SECURITY')[0]; if (result != null) { // now you can access the content for above simple example // it suffices to do e.g. alert(result.firstChild.nodeValue); } if (security != null) { alertt(security.firstChild.nodeValue); } Depending on which browsers you want to support there are other solutions, W3C DOM Level 2 implementations (like older Mozillas, like Opera 8) do not expose a property that concatenates the text contents of all children and desendants in a element node so for that you would need to write your own. For Firefox or newer Mozillas and for Opera 9 there however is the textContent property, for MSXML in IE there is the text property so restricted to those you could also script e.g. if (result != null) { if (typeof result.textContent != 'undefined') { alert(result.textContent); } else if (typef result.text != 'undefined') { alert(result.text); } } Firefox and Opera 9 also support the W3C DOM Level 3 XPath API. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
XML Data by Name instead of childNode Array?
Top