473,395 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Modifying an XML file with PHP

mikek12004
200 100+
I have an XML file representing categories like this
Expand|Select|Wrap|Line Numbers
  1. <?xml version='1.0' encoding='utf-8' ?>
  2. <bank>
  3. <img>
  4.     <src>img/GF0813-1_thumb.jpg</src>
  5.     <title>classicΙ</title>
  6.     <caption>Click here</caption>
  7.     <link>main.php?page=2&amp;id=125</link>
  8.     <target>_self</target>
  9. </img>
  10. <img>
  11.     <src>img/PBE0720008_thumb.jpg</src>
  12.     <title>BULLETS</title>
  13.     <caption>Click here</caption>
  14.     <link>main.php?page=2&amp;id=117</link>
  15.     <target>_self</target>
  16. </img>
  17. </bank>
  18.  
where each <img></img> represents a category which has an image (<src>), title (<title>), caption (<caption>), link and target of that link.
Now when I add a category its easy to open the xml like an ordinary file and add the corresponding <img> at the end, but when I delete/modify a category I have to check where the corresponding <img></img> exists (each category/<img> has a unique id going into the <link>) and modify that how can I do it? (My initial idea involves using explode with </img>, is there a better way to handle xml through PHP?)
Jun 19 '09 #1
1 1557
Dormilich
8,658 Expert Mod 8TB
@mikek12004
of course. PHP comes with a bundle of XML manipulation functionality:
SimpleXML
DOM
SAX type parsers (XMLReader, XMLWriter, XML Parser)
Jun 19 '09 #2

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

Similar topics

2
by: yvan | last post by:
I was wondering if someone here could help me with modifying this PHP template so that it does something very specific for me. My knowledge of PHP is very limited (I'm more of a Cold Fusion...
5
by: jrmsmo | last post by:
Hi I have a document as follows: <?xml version="1.0"?> <metadata xml:lang="en"> </metadata> I want to change the document so it looks as follows: <?xml version="1.0"?> <metadata...
1
by: Max Khitrov | last post by:
Hello everyone, I'm working on a VS .NET add-in that will allow developers to use Subversion software from within the IDE (much like Source Safe). Ideally, I would like for my plug-in to be able...
2
by: Yavuz Bogazci | last post by:
Hi, i am reading the LastAccessTime, LastWriteTime and DateofCreation of a file. The second and third are working well, but each time i want to read the LastAccessTime, its set to "now". How can...
6
by: MackS | last post by:
Hello everyone I am faced with the following problem. For the first time I've asked myself "might this actually be easier to code in C rather than in python?", and I am not looking at device...
13
by: Robin Becker | last post by:
When young I was warned repeatedly by more knowledgeable folk that self modifying code was dangerous. Is the following idiom dangerous or unpythonic? def func(a): global func, data data =...
2
by: rk | last post by:
I have the following library.xml file coming from a system, this can't be modified. ____________________________________________________________________________ <?xml version="1.0"...
0
by: svallarian | last post by:
C# beginner here. I'm writing serialized records to a file, and I'm able to add and read them back to the program no problem. However, when I try to modify the record by reading the record,...
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
5
by: IUnknown | last post by:
Ok, we are all aware of the situation where modifying the folder structure (adding files, folders, deleting files, etc) will result in ASP.NET triggering a recompilation/restart of the application....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.