www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to read CDATA with Javascript

  1. #1
    Join Date
    Apr 2009
    Posts
    1

    How to read CDATA with Javascript

    Hi,
    I want to read the parameters from CDATA within a HTML page, similar like the following:
    <html>
    <head>
    <title>AnyTitle</title>
    </head>
    <body>
    <h1>Header</h1><br/>
    Text1
    <br/>
    Text2
    <script defer="defer" type="text/javascript"><!--//--><![CDATA[//><!--param1="value1";param2="value2";//--><!]]></script>
    </body>
    </html>

    I can find the script element, but unfortunately I don't know how to proceed.
    Any ideas are welcome!!!

    Thanks in advance, _.stan._

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    according to what i had tried, it seem that CDATA doesn't create a node inside script tag despite the DOM describe that a Character DATA create a node in document. i guess it is because content inside script tag use Text interface. however, to read the content you can do something as:
    Code:
    document.getElementsByTagName('script')[0].firstChild

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles