473,770 Members | 7,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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>Mo nty</first_name><sur name>Burns</
surname></person></root>

This is better:

<?xml... ?>
<root>
<person>
<first_name>Mon ty</first_name>
<surname>Burn s</surname>
</person>
</root>

I have an idea involving lots of str_replace's - e.g.
str_replace("<p erson>", "\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 1132

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

Similar topics

1
4660
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 (defined in the DTD but apparently libxml is not trying to fetch the URL). Both DOM and SimpleXML fill my window with warnings like: Warning: DOMDocument::load() : Entity 'nbsp' not defined
5
5825
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 file. If more levels are added in XML file, I need to change ASP code as well. i.e. For every additional level in XML file, I need to add an additional loop in ASP page. My question is: is it possible that ASP code is unchanged, even XML file...
3
5633
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
1747
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 range(0,width):
1
2076
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 command line. My version info as follows: PHP 5.1.2 (cli) (built: Jan 11 2006 16:40:00) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
2
9130
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
11405
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 anyone have a simple code snippet? Either VB or C# will be perfect.
1
2708
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 hearing that DirectShow may have the answer. However, after downloading the latest DirectX SDK it says that DirectShow is now obsolete but it doesn't say what I should be using. I am thinking that I need to set up some tcp network streaming to...
0
1390
by: yawnmoth | last post by:
First, here's my code: <?php $xml = new DOMDocument(); $xml->preserveWhiteSpace = true; $xml->loadXML(' <html> <head/> <body/>
2
10698
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> <subelement1>aa</subelement1> <subelement2>aa</subelement2> </element1>
0
9592
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10004
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9870
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7416
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.