SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Text nodes

  1. #1
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Text nodes

    I have some HTML code like:
    Code HTML4Strict:
    <a href="function.strval.php">
        <img height="7" width="11" alt="<" src="/images/caret-l.gif"/>
        strval
    </a>

    Here I have a a tag and then a image node and a text node. How can I get all the text nodes (that are child nodes of node a) inside the node a in PHP?

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I'm not mistaken, the text would be elem.ChildNodes.item(1)

  3. #3
    SitePoint Addict ArunB's Avatar
    Join Date
    Jun 2008
    Location
    Hyderabad
    Posts
    252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for quick reply.

    I don't know the position of the text node, the HTML comes from user input.

  4. #4
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ArunB View Post
    Thanks for quick reply.

    I don't know the position of the text node, the HTML comes from user input.
    In that case, you would probably need to iterate over the child nodes and check the nodeType of each one.


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
  •