New to PHP: Need to update an xml file with html & php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shinerankin
    New Member
    • Sep 2008
    • 1

    New to PHP: Need to update an xml file with html & php

    Hi Guys & Gals:

    I have a project with using flash that is updated with an xml file. The developer went belly up and is no longer assisting with anything. I need to write a simple html or php form to update and possibly edit current items in the xml file.


    Here is my current xml file:
    [code=xml]
    <?xml version="1.0" encoding="UTF-8"?><sports>

    <sport id="6" game="Softball" gameStatus="F" home="Tift County" away="Warner Robins" homeScore="0" awayScore="5" notes="" division="AAAAA "/>

    <sport id="25" game="Football" gameStatus="F" home="Coffee" away="Pierce County" homeScore="41" awayScore="0" notes=" Coffee looks to build on victory over Ware" division="AAAAA "/>
    <sport id="26" game="Football" gameStatus="F" home="Valdosta" away="Windsor Forest" homeScore="48" awayScore="7" notes="" division="AAAAA "/>
    <sport id="27" game="Football" gameStatus="F" home="Camden Co." away="Columbia, Fl" homeScore="30" awayScore="0" notes="" division="AAAAA "/>
    <sport id="28" game="Football" gameStatus="F" home="Bradwell Inst." away="Wayne Co." homeScore="28" awayScore="13" notes="" division="AAAAA "/>
    <sport id="29" game="Football" gameStatus="1" home="Richmond Hill" away="Johnson, Sav." homeScore="0" awayScore="0" notes="moved to 19th" division="AAAAA "/>
    <sport id="30" game="Football" gameStatus="F" home="Benedicti ne" away="Savannah" homeScore="30" awayScore="26" notes="" division="AAAAA "/>
    <sport id="31" game="Football" gameStatus="F" home="Ware Co." away="Burke Co." homeScore="34" awayScore="27" notes="Demtrius Wright returns a punt for 75 yard touchdown." division="AAAA"/>
    <sport id="32" game="Football" gameStatus="F" home="Cook " away="Brunswick " homeScore="14" awayScore="30" notes="" division="AA"/><sport id="33" game="Football" gameStatus="F" home="Charlton Co." away="First Coast" homeScore="32" awayScore="18" notes="" division="AA"/>
    <sport id="34" game="Football" gameStatus="F" home="Statesbor o" away="Groves" homeScore="30" awayScore="6" notes="" division="AAAAA "/><sport id="35" game="Football" gameStatus="F" home="Swainsbor o" away="Vidalia" homeScore="25" awayScore="26" notes="" division="AAA"/></sports>
    [/code]
    I need a way to update and edit this for the end user.

    I'm open to suggestion as I have written a bit of asp but have very little experience with php/
    Last edited by Atli; Sep 11 '08, 06:19 AM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    I would look into SimpleXML.
    Take a look at the examples there to see how to use it.

    If that doesn't work for you (which it should), there are several other options available.

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      if you're using php5 you may want to update/maintain you xml file with the DOMDocument class. It looks relatively easy since you only have to add one element (with several attributes).

      another possibility is to process the file (as text) line by line, assuming that there is only one element per line.

      regards

      PS: the use of DOMDocument is comparable to the use of the DOM in JavaScript

      Comment

      Working...