anarchyEric Posted May 14, 2009 Share Posted May 14, 2009 Hello, I need help figuring out how to do some XML editing with PHP. I'm writing software for an organization that offers recreational programs and I need to format the output into an XML file. The easy part is creating the XML file, as I can do that with the basic file operations in PHP. What I need to do now is edit specific nodes within the file without simply re-writing the whole thing. Here is the example XML (slightly truncated): <program> <program_id>4</program_id> <name>Some Program</name> ... <registration_end_date>05/25/2009</registration_end_date> <package_list> <package> <package_id>2</package_id> <package_name>T-Shirt</package_name> </package> <package> <package_id>5</package_id> <package_name>Food Pass</package_name> </package> </package_list> </program> What I'm having trouble doing is editing the <package_list> portion. Packages are added separately from editing the program, so I just want to update the package section whenever they are changed without touching the rest of the XML. I've played around with simpleXML, but I'm still not sure exactly how to get down to just the <package_list> section and only update the packages. I don't mind recreating the <package_list> section by removing all packages and re-adding them every time there is an update, but I want to avoid recreating the entire file. If you need further explanation or clarification, feel free to ask. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.