By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,023 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

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

P: 1
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:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?><sports>
  3. <sport id="6" game="Softball" gameStatus="F" home="Tift County" away="Warner Robins" homeScore="0" awayScore="5" notes="" division="AAAAA"/>
  5. <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"/>
  6. <sport id="26" game="Football" gameStatus="F" home="Valdosta" away="Windsor Forest" homeScore="48" awayScore="7" notes="" division="AAAAA"/>
  7. <sport id="27" game="Football" gameStatus="F" home="Camden Co." away="Columbia, Fl" homeScore="30" awayScore="0" notes="" division="AAAAA"/>
  8. <sport id="28" game="Football" gameStatus="F" home="Bradwell Inst." away="Wayne Co." homeScore="28" awayScore="13" notes="" division="AAAAA"/>
  9. <sport id="29" game="Football" gameStatus="1" home="Richmond Hill" away="Johnson, Sav." homeScore="0" awayScore="0" notes="moved to 19th" division="AAAAA"/>
  10. <sport id="30" game="Football" gameStatus="F" home="Benedictine" away="Savannah" homeScore="30" awayScore="26" notes="" division="AAAAA"/>
  11. <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"/>
  12. <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"/>
  13. <sport id="34" game="Football" gameStatus="F" home="Statesboro" away="Groves" homeScore="30" awayScore="6" notes="" division="AAAAA"/><sport id="35" game="Football" gameStatus="F" home="Swainsboro" away="Vidalia" homeScore="25" awayScore="26" notes="" division="AAA"/></sports>
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/
Sep 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 5,058

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.
Sep 11 '08 #2

Expert Mod 5K+
P: 8,639
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.


PS: the use of DOMDocument is comparable to the use of the DOM in JavaScript
Sep 11 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.