![]() |
Extracting contents of CDATA section in XML using Javascript
Hi All,
I need to extract contents of CDATA section in XML using Javascript. The XML looks like this Code:
<batsmen order="6">Please help. Regards, Shanker |
Quote:
Code:
- <![CDATA[ c ]]> if you can't control the data, you can still clean it up in javascript: Code:
function trim(s){ return String(s).replace(/^\s+|\s+$/g,''); }Code:
var string=" abc "; |
Hi rnd me,
Thanks for the help. But, I am not able to extract the contents of the <howout> tag. Please help. Regards, Shanker |
Quote:
post the code you're using and i'll tell you what's wrong. |
Hi rnd me,
Herez the code - Code:
if (window.XMLHttpRequest)Please help. Thanks. Regards, Shanker |
Quote:
Herez the code that was used to parse the <howout> tag - Code:
if (window.XMLHttpRequest)Please help. Regards, Shanker |
Extracting CDATA
Hi Shanker,
Consider these couple of biterscripting commands. They will retrieve the "c" from CDATA. Code:
var str xml, cdatastex (string extractor) command is at http://www.biterscripting.com/helppages/stex.html . |
CDATA sections are also nodes of the DOM. You must simply circle through nodes and see which one has the property nodeType==4 and retrieve the text inside as being its firstChild.NodeValue
|
| All times are GMT +1. The time now is 08:43 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.