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

PHP & DOM XML : Formating the output file

Hi,
I need to manipulate XML files with PHP. So i need to extract and
insert nodes in my files.

For the extraction : no problem with XPath, it works fine.

But, for inserting new nodes, it's more complicated. It's works but I'm
experiencing some XML code formating problems

Lets take an example of XML source file, in which I have to insert data
:

<A>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
</A>
In this file I must insert a new group of tags (DTD complient tags) in
order to obtain this output file

<A>
<New>
<Data1></Data1>
<Data1></Data1>
</New>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
</A>
But, instead I obtain this output :

<A>
<Objects>
<Obj>foo</Obj>
<Obj>bar</Obj>
</Objects>
<New><Data1></Data1><Data1></Data1></New></A>

My new group of tags has been inserted at the and of my file, and my
XML code is not correctly indented.

What can I do to fix this?

Thanks

Mar 1 '06 #1
0 1185

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

Similar topics

6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
1
by: DrTebi | last post by:
Hello, I have the following problem: I used to "encode" my email address within links, in order to avoid (most) email spiders. So I had a link like this: <a...
5
by: Neven | last post by:
Hi, Is there a trick how to use CSS in newsletters ? I'm trying to use CSS formating when creating newsletter, but when i recieve CSS newsletter, no CSS formating is visible, all the text is...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
6
by: cj | last post by:
I'm receiving an xml formatted string that I pull data from by reading it into an xml document like this: Dim doc As New Xml.XmlDocument doc.LoadXml(respstr) Dim co_name As Xml.XmlNodeList =...
2
by: Amit | last post by:
I have assigned a simple xml into a XmlReader. A switch case loops through the nodes and writes the data to XmlWriter object which is initialized to a xml file. The output xml file is correctly...
1
by: msinghindia | last post by:
I am creating an application which need to convert document files into XML. Then read the xml files for specific words in specific format. I am using Microsoft.Office.Interop for converting the...
3
by: Pappy | last post by:
SHORT VERSION: Python File B changes sys.stdout to a file so all 'prints' are written to the file. Python file A launches python file B with os.popen("./B 2>&^1 >dev/null &"). Python B's output...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
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...

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.