Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting contents of <script> container



On Sep 27, 2005, at 10:25 AM, Michael Hanna wrote:

in an XML document there is a <script> container that is structured like so:

<script><![CDATA[ // >

contents

]]></script>

I can get > 0 in a nodelist, but I can't seem to access 'contents'. This code returns a warning that aNode doesn't respond to -outerHTML(then why does -documentElement?). When I try -nodeValue I get a blank string.

    nodeList = [domDoc getElementsByTagName:@"script"];
    for(i = 0 ; i < [nodeList length] ; i++)
    {
        aNode = [nodeList item:i];
        
        if([aNode isKindOfClass:[DOMElement class]])
        {
            aNodeSource = (DOMHTMLElement *)[aNode outerHTML];
            NSLog(@"[DOMElement class] %@", aNodeSource);
        }     
    }

If you dump aNode you'll see that it's an object of class DOMCharacterData. That's not an HTML element, so you can't call the outerHTML method on it.

That's inconvenient, and it would be nice to have something like outerHTML that works on non-HTML elements.

    -- Darin

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webkitsdk-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.