Announcement
Collapse
No announcement yet.
Indentation in XML from AMS
Collapse
X
-
You should recurs through every table item and tab each incursion. I would write a local function to take care of that right before saving the string to a text file.
-
Got it CS, thanks.
Although I was setting the code using a string, the same you see in the before post.
Now I have another problem.. (I always have one) When I set the code it works fine with \r \n \t special chars but not if I use them at the beginning of my string.
the \r\n\t at the beginning are totally ignored and this turns in something like this:Code:XML.InsertXML("Tray/Settings", "\r\n\t<Application/Settings>\r\n\t\t<Name>"..sName.."</Name>\r\n\t\t<Path>"..sPath.."</Path>\r\n\t</Application>", XML.INSERT_AFTER);
Tried to use twice the XML.InsertXML() function;Code:<Tray> <Settings/> <Application> <Name>_appname_</Name> <Path>_apppath_</Path> </Application> </Tray>
this applies the tabbed whitespace where it should be, but the next time I use XML.InsertXML() the text goes again at a new line writing something like this:Code:XML.InsertXML("Tray/Settings", "\r\n\t", XML.INSERT_AFTER); XML.InsertXML("Tray/Settings", "<Application/Settings>\r\n\t\t<Name>"..sName.."</Name>\r\n\t\t<Path>"..sPath.."</Path>\r\n\t</Application>", XML.INSERT_AFTER);
How can I write the element where it should be, returning this ?Code:<Tray> <Settings/> <Application> <Name>_appname_</Name> <Path>_apppath_</Path> </Application> </Tray>
Code:<Tray> <Settings/> <Application> <Name>_appname_</Name> <Path>_apppath_</Path> </Application> </Tray>
Last edited by T3STY; 08-02-2010, 12:21 PM.
Leave a comment:
-
If you're using xml commands, those special characters are not going to have the effect you're after. If you get the xml (XML.GetXML()) and add those specials while in string format they will work. After altering your string, make sure to set the xml again using XML.SetXML().
Whether or not those tabs and line breaks will remain is unknown to me since I can't test it right now.
Leave a comment:
-
Indentation in XML from AMS
Hey guys, I'm trying to use XML.InsertXML() to insert new elements in a file. It works but I'd like also to have some indentation... it's really hard to read in a XML file with no indentation..
What I've tried for now is the string special chars like \r \n \t after the xml element I'm adding but it doesn't work..
This should be written in the XML file:Code:XML.Load("TrayProcesses.xml"); XML.InsertXML("Tray/Settings", "\r\n\t<Application>\r\n\t\t<Name>"..sName.."</Name>\r\n\t\t<Path>"..sPath.."</Path>\r\n\t</Application>", XML.INSERT_AFTER); XML.Save("TrayProcesses.xml");
but instead it writes this:Code:<Tray> <Settings/> <Application> <Name>_AppName_</Name> <Path>_AppPath_</Path> </Application> </Tray>
Any idea why it doesn't work ?Code:<Tray> <Settings/><Application><Name>_AppName_</Name><Path>_AppPath_</Path></Application> </Tray>
EDIT
I don't know why, I wrote the code again and now it works.. I can't understand why it didn't worked before...Last edited by T3STY; 08-02-2010, 12:20 PM.Tags: None
Leave a comment: