Some XML how to questions

Anyone, especially newbies, asking for help with photoshop scripting and photoshop automation - as opposed to those contributing to discussion about an aspect of photoshop scripting

Moderators: Patrick, Mike Hale, xbytor, Larry Ligon, Andrew, PS-Moderators

Some XML how to questions

Postby paulemasters » Tue Feb 28, 2012 1:29 am

Hello:

PC W7 64 bit Ultimate CS3.

I am just about done with the current XML project. I keep wondering what I have missed or are doing wrong because It is much easier than I thought it would be. :mrgreen:

There are a few things that are happening and I hope someone here can help me fix them, if possible.

First, when creating the XML object, the declaration line is skipped, or at least it is skipped when writing the updated object back to a file:
<?xml version="1.0" encoding="utf-8"?>

I did a test with a file with out that line and the program that will use the output doesn't seem to mind it not being there. In fact, when it updates the file it adds it. While that may not matter, I don't like leaving things out of other products files.

Second, while I realize that it may not be strict XML format, some of the 'empty' elements have:
<Commands />
instead of the <Commands></Commands> and the script writes those lines back as:
<Commands/>
with out the space before the slash.

I have poked around on the WEB a little but can't find if that is a valid format or not.
I tested the file with that format (no space) and the program doesn't seem to mind. Again, it updated the lines to the way it wanted them - with the space.

Even though the book says all the attributes for XML are true, except for whitespace, they were false. Making all of them true, even the whitespace one, doesn't seem to have any effect on the above two situations.

Thanks for any comments.

Paul Masters
paulemasters
 
Posts: 56
Joined: Thu Apr 28, 2011 9:32 pm

Re: Some XML how to questions

Postby csuebele » Tue Feb 28, 2012 2:29 pm

Both of the things you mentioned are fine. If you don't have content in you node, when you write the XML file, it will condense the beginning and end tags together. Most of the time this is fine, but I was doing a project were I wanted to save white spaces, and unless there were some other element with those white spaces they were removed. I ended up putting '^^^' in my content when writing it, then stripping it out as it was read.
csuebele
 
Posts: 145
Joined: Tue Nov 25, 2008 1:46 pm

Re: Some XML how to questions

Postby paulemasters » Wed Feb 29, 2012 4:53 pm

Hello:

Thanks for the information.

I had thought of something similar to what you are doing but as long is it is correct with XML and my tests show that the program that will read the file has no problems, I will leave things as they are.
I don't have control of the 'reading' program, so I can't make the changes as the file is read like you are doing.

Thanks again for the help.

Paul Masters
paulemasters
 
Posts: 56
Joined: Thu Apr 28, 2011 9:32 pm


Return to Help Me

Who is online

Users browsing this forum: No registered users and 3 guests