Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

DOM Scripting - accessing XML CDATA values

Explorer ,
Jun 11, 2009 Jun 11, 2009

HI Folks,


Not sure if this is the write forum, but I'm trying to use Javascript to output XML values onto my webpage, see below.

This works fine, but when I try and get he values in a CDATA tag, I get undefined or null.

Can anyone please tell me how to get CDATA content?

<script type="text/javascript"

xmlDoc=loadXMLDoc("news.xml");

x=xmlDoc.getElementsByTagName('title');
for (i=0;i<x.length;i++)
{
document.write(x.childNodes[0].data);
document.write("<br />");
}
</script>

XML

<items>
  <item>
    <title>
      <![CDATA[text goes in here]]>
    </title>
</item>
</items>
604
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 12, 2009 Jun 12, 2009

I think you will have more success on a JavaScript forum.

Mack

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 12, 2009 Jun 12, 2009
LATEST

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources