PHP expert needed - Reading and Writing XML

Discussion in 'Web Design and Development' started by noelister, Jul 12, 2006.

  1. noelister macrumors 6502

    Jan 15, 2005
    I am trying to create a simple Admin page to edit existing XML files and create new XML files. Currently I am using PHP and the SimpleXML parser ( is there a better parser for this). I created a script that can read and write to a specific XML file. However, I would like to be able to use this script on any XML file that pertains to my site. This is where the problem lies, not all my XML files use the same tags. Examples being, news.xml has a different format as gallery.xml. So, I need a function that could loop through the XML file to find the format and tag names (is this even possible)?

    thanks for anyhelp!
  2. angelneo macrumors 68000

    Jun 13, 2004
    Did you try this method to loop through the children nodes? SimpleXMLElement->children(). link

    You can try other php xml library other than simpleXML. I have used this before and it works for simple xml structures.

    Another way, I can suggest is using your Admin page with javascript to edit the xml document and then passing the entire xml string to php. Either that or with actionscript, both are very similar in their syntax.

Share This Page