The substringData() method gets a string from the CDATA node.
CDATANode.substringData(start,length)
The following code fragment loads "books_cdata.xml" into xmlDoc using loadXMLDoc() and gets the "Stun" string form the first CDATA element:
xmlDoc=loadXMLDoc("books_cdata.xml");
x=xmlDoc.getElementsByTagName("html")[0].childNodes[0]
y=x.substringData(3,4);
document.write(x.nodeValue); document.write("<br />"); document.write(y);}
Output:
Stunning! Stun
substringData() - insert a string to a comment node
Jump to: Top of Page or HOME or Printer friendly page
W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2008 by Refsnes Data. All Rights Reserved.