OZONE Asylum
Forums
DHTML/Javascript
Get the html code inside an xml tag
This page's ID:
30388
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Of course it does give you the whole XML's markup since you grab the entire responseText. Here what you need to do to only get the markup of the first CODE node:[code]var code = yourXhrObject.responseXML.getElementsByTagName('code'); if( !code || !code.length ) { alert( 'no CODE node' ); return false; } var tempdiv = document.createElement('div'); tempdiv.appendChild( code[0] ); alert(tempdiv.innerHTML); return true;[/code]or[code]var code = yourXhrObject.responseXML.getElementsByTagName('code'); if( !code || !code.length ) { alert( 'no CODE node' ); return false; } var tempdiv = document.createElement('div'); tempdiv.innerHTML = (new XMLSerializer()).serializeToString( code[0] ) );[/code]Note that the later will also include the markup of the CODE node itself so you'll certainly need to loop through its children, and maybe use a DocumentFragment. Also note that your XML markup is invalid. The DIV tag inside the CODE tag isn't closed. And again, unless this is for a specific web application/widget, I must that this approach doesn't sound right. HTH, [url=http://www.p01.org/][sigrotate][img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_love.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_love_small.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_charly.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_dk.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_reason.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_galaxy.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_neon88x31.gif[/img]|[img]http://poi.ribbon.free.fr/files/p01_ozoneasylum_sig_teapot.png[/img][/sigrotate][/url]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »