Menu
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
parsing XHTML with JavaScript?
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: 4952048"] XHTML is XML. So an XML parser can deal with it and build an XML DOM, if the parser knows XHTML then it can even build an XHTML DOM for the XHTML elements in the namespace [URL]http://www.w3.org/1999/xhtml[/URL]. For instance with Mozilla you can do var xmlDoc = new DOMParser().parseFromString([ '<html xmlns="[URL]http://www.w3.org/1999/xhtml[/URL]">', '<head>', '<title>Example</title>', '</head>', '<body>', '<p id="p1">Kibology for all.</p>', '</body>', '</html>' ].join('\r\n'), 'application/xml'); var ps = xmlDoc.getElementsByTagNameNS('[URL]http://www.w3.org/1999/xhtml[/URL]', 'p'); var p = ps[0]; alert(p + ': ' + p.id); and p is an HTMLParagraphpElement having an id property as the parser has recognized the namespace of the element and built the XHTML DOM. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
parsing XHTML with JavaScript?
Top