The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> XML Programming
|
Probem with tab space when insert a new XML element
Discuss Probem with tab space when insert a new XML element in the XML Programming forum on Dev Shed. Probem with tab space when insert a new XML element XML Programming forum discussing XML and related technologies, including XUL and XSL. XML is a self-describing file format, designed for maximum compatibility between applications.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 3rd, 2011, 12:04 PM
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 4
Time spent in forums: 1 h 3 m 44 sec
Reputation Power: 0
|
|
|
Probem with tab space when insert a new XML element
Hi, I am new in editing xml and I have met this problem: I edit xml files using lua commands and when I replace or add a new xml row, next row's tab space (or one empty space character) is disappeared. It is something like:
Code:
<some element>
<child1>
<child2>
<new added child>
<child 3>
<child4>
<some element/>
Moreover, in the case of a replacement, if there was a comment in that line, it goes in next line alone:
Code:
<some element>
<child1>
<child2>
<new added child>
<!--comment of replaced child 3-->
<child4>
<some element/>
This is rather a cosmetic problem and does not actually affect the structure of the xml but if there are many such changes I cannot read easily the xml any more and search for other potential mistakes. I tried adding page breaks and such with no luck so far. Is there a solution?
Thanks!
|

October 3rd, 2011, 01:38 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
What's your code to insert into the XML? If you're doing it manually then you need to copy whitespace from the next node. Unless it's a closing tag, then you need to add one more level of indentation.
For example,
Code:
<a>
<b>_
____<d>
</a>
Code:
<a>
<b>_
____<c>
<d>
</a>
|

October 3rd, 2011, 02:19 PM
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 4
Time spent in forums: 1 h 3 m 44 sec
Reputation Power: 0
|
|
|
The addition or replacement is happened automatically by a Lua command. Since this command must be in one line what I have to add before or/and after "<c>" so I can have the result (the red spaces) in <d> element? Because the problem appears in the very next line (<d> in your example) and not in the one I add (<c> in your example).
|

October 3rd, 2011, 02:39 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
Quote: | Originally Posted by Arispezon The addition or replacement is happened automatically by a Lua command. |
Which would be...?
|

October 3rd, 2011, 02:47 PM
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 4
Time spent in forums: 1 h 3 m 44 sec
Reputation Power: 0
|
|
|
XML.InsertXML("a/b", "<c>", XML.AFTER);
or if I want <c> to replace <b> it should be:
XML.InsertXML("a/b", "<c>", XML.REPLACE);
|

October 3rd, 2011, 03:40 PM
|
 |
Still alive
|
|
Join Date: Mar 2007
Location: Washington, USA
|
|
It doesn't seem like there's any way to fix the indentation in Lua. At least not according to the documentation.
A few editors have a Reformat Document-type action, and most XML viewers will present the markup reformatted for you to see...
|

October 3rd, 2011, 04:33 PM
|
|
Registered User
|
|
Join Date: Oct 2011
Posts: 4
Time spent in forums: 1 h 3 m 44 sec
Reputation Power: 0
|
|
|
O.K. I thought that it was something I didn't know about it..
Thanks a lot Requinix for your hep.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|