473,387 Members | 1,897 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,387 software developers and data experts.

Using DOMDocument->SaveXML ... is it possible to have XML more readerfriendly?

Hi,

When using the Save() and SaveXML() functions I am able to output xml
on a screen or save to file. The only issue is that I would prefer to
have it a bit more readable. For example:

Current:

<?xml... ?><root><person><first_name>Monty</first_name><surname>Burns</
surname></person></root>

This is better:

<?xml... ?>
<root>
<person>
<first_name>Monty</first_name>
<surname>Burns</surname>
</person>
</root>

I have an idea involving lots of str_replace's - e.g.
str_replace("<person>", "\n <person>", $xml) - but thought Id check
to see if maybe an option or setting exists to do this. Obviously my
xml is a bit more complicated that the above so it would help as it is
for an external API so I want it to be easy to read. I had a look in
the PHP Docu and notice that there are options you can set in Save and
SaveXML but didnt seem to be any to do what I was after (or maybe I
just didnt understand them properly). Any help would be much
appreciated.

Burnsy
Feb 10 '08 #1
0 1118

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Harry Potter | last post by:
Hi, I have a problem with both DOM and SimpleXML. I'm reading an XML file which has a DOCTYPE declaration using a public identifier and an URL. the XML file contains some &nbsp; entities...
5
by: Matt | last post by:
I want the ASP page retrieves data from XML file and put in table. However, is it possible that the ASP code doesn't know the look of XML file structure? The following is my ASP code and XML data...
3
by: Dean Slindee | last post by:
Newbie question: Any easy way to convert a DOMDocument to a System.Xml.Document? Dim DOMDocument As DOMDocument40 to this Dim xmlDoc As System.Xml.XmlDocument Thanks,
29
by: Tuvas | last post by:
I have a function in a program that works something like this. def load_pic_data(width,heigth,inpdat, filt=TRUE): data='' total=0 tnum=0 size=100 for y in range(0,heigth): row='' for x in...
1
by: pbali | last post by:
Hi, I have a PHP5 script that creates an XML file and sends the file via FTP. The script runs from the browser smoothly. No problem. I am trying the use the same script from the windows xp...
2
by: J˙Giusł vs ::NRG::ius | last post by:
Hi all. I have this script ----------------------------------------------------------- <?php $doc = new DOMDocument(); $doc->load('books.xml'); echo $doc->saveXML(); ?>
7
by: pamela fluente | last post by:
hi, What is the cleanest and effective way to use the PrintDocument object to print directly to a pdf file "myfile.pdf" (with no prompt to the user: just print to file and make pdf) ? Does...
1
by: Jerry Spence1 | last post by:
I'm struggling to get started on this subject as I can find out so little information about DirectX I have some IP Cameras and I am trying to display the video and also save the file, and I am...
0
by: yawnmoth | last post by:
First, here's my code: <?php $xml = new DOMDocument(); $xml->preserveWhiteSpace = true; $xml->loadXML(' <html> <head/> <body/>
2
by: Samudaya | last post by:
Hi, I have a application which has a xml file reading and wrting. I want to remove some element in xml file by using php. <?xml version="1.0" encoding="UTF-8"?> <element1>...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.