SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parsing an XML Like String in PHP

    So I have a string like this:

    Code:
    <note>
    <url>http://google.com/</url>
    <notes>Notes about the URL Google</notes>
    </note>
    <note>
    <url>http://yahoo.com/</url>
    <notes>Notes about Yahoo</notes>
    </note>
    Here are the ways I need to manipulate the string.

    Sorry XML is kind of new to me so i'll write it like I would if it were a SQL Database.

    I need to update the notes based on the URL (e.g. UPDATE notes WHERE url='http://google.com')

    I also need to detect if a url exists and append to the string if it doesn't exist.

    For example:

    If (Bing) Does not Exist

    Then append this to the end of the string: "<note><url>http://bing.com</url><notes>Notes About Bing</notes></note>"


    Any ideas on how to do this? It'd be nice if PHP had some built in functions to build and create XML trees like this.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    64 Post(s)
    Tagged
    0 Thread(s)
    So throw an XML header on the thing and parse it with SimpleXML?

  3. #3
    SitePoint Evangelist JordashTalon's Avatar
    Join Date
    Dec 2008
    Posts
    505
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm really new to XML, how would I do that?


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
  •