June 27th, 2002, 09:30 AM
Dynamically saved XML file doesn't follow structure
XML Newbie here - please be kind. I am using an XML file as a very small database, and my script can successfully read and manipulate the data. It can also add new entries, and save them to the file.
The problem is, when the script saves the XML file, the new entries are all on one run-on line and do not follow the indentation/structure pattern of the file.
In the following listing, I start with entries 0 and 1 already in the file, then I add entry 2, and the file becomes deformed:
<title>Job Title 1</title>
<info>Job info 1</info>
<contact>Contact info 1</contact>
<title>Job Title 2</title>
<info>Job info 2</info>
<contact>Contact info 2</contact>
<job id="3"><title>Job title 3</title><info>Job info 3</info><contact>contact info 3</contact></job></main>
I am using XML DOM with ASP, although I doubt this is the problem or source of any concern at all (since it's just abstraction methods for reading/parsing the XML file, there is no control for such details).
June 27th, 2002, 09:40 AM
I had to do something similar and I used something like this:
and it worked fine. I'm new too so anyone with anything better should feel free to correct me...
June 28th, 2002, 08:31 AM
Any time I have done something similar with php, whether it is writing HTML or XML, I use the new line character "\n" and then if I want to use a tab then I use "\t".
June 28th, 2002, 07:45 PM
Well the thing is, this isn't like a normal file read/write operation. The XML DOM object abstracts that part, so all you do is like myxml.open(), myxml.appendnode(), myxml.save()
That's why I can't seem to get any control over it - because it does everything for me.
I was thinking about just making a simple flat-file database thing, but you know how pride starts messing with you and you think you can become an XML developer within a day?....