Results 1 to 2 of 2

Thread: have a probem with createTextNode

  1. #1
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default have a probem with createTextNode

    Hello, im trying to make a rss reader using DOM to populate it but I got a problem. I used this code for the description:
    var desc = createTextNode(<the description array>);

    But some sites have extra tags in the description tag such as pictures and links so if i generate it as a text node I will get the tags as text like this:
    some random description <img ... /> <a href.... >link</a>
    instead of:
    some random description <the real image> <the real link>

    I solved this with innerHTML but i was just wondering if theres another way to deal with this?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    innerHTML is the best way here. You could write your own HTML parser (and if you've got time, by all means do and use it as a backup in case innerHTML isn't available) but the native parser will always surpass it by far in terms of speed.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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