Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2002
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts

    expat, Getting contents of a tag

    Hello, I am working with an xml conversion that puts the contents of the <item> tag in quotes and uses it in a javascirpt. The only problem is, the contents of the <item> tag might contain its own quotes, Is there a way that I can, when I parse the beginning of the <item> tag, parse all the way through to the end of the tag and change the " to \"? Thanks a lot.
    Example:
    <item>Everyone say "Hello!"</item>
    would need to be converted into:
    "Everyone say \"Hello!\""
    ~evlich

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    can you not just addslashes() before printing ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Montreal, Canada
    Posts
    644
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you only want to add slashes to the quotation marks you can try the str_replace() function.

    http://www.php.net/manual/en/function.str-replace.php


  •  

    Posting Permissions

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