• 0

directly editing plaintext file


Question

oops Sorry guys, i forgot to add that this is about XML into the title

mods please change it for me thanks

hi guys, i have a program that saves its files in a plaintext xml-like format

<default boundary="(-25.5,-1.02000001334e-006,-25.5,25.5,100.0,25.5)"><sky materialName="white0" type="skyBox" /><ambient b="0.0" g="0.0" r="0.0" /><camera farClip="0.0" focus="(0.360324, 1.13116, 23.4453)" nearClip="0.5" pitch="-21.3439769745" roll="0.0" viewportBackgroundColour="(0.0, 0.0, 0.0)" yaw="18.0628833771" zoom="8.33835697174" /><lights><light id="directional_light00" name="directional_light0" orientation="(0.51420056819915771, 0.44506224989891052, 0.51390737295150757, -0.52289277315139771)" selectable="False" visible="False" what="directional_light0" x="40.9265975952" y="32.6617431641" z="62.0254325867"

and so on and so on

the problem is that its all written in a single line, is there a way to automatically add line breaks to show the hierarchy and structure better?

another thing, i would like to import a set of numbers from one file to another

here is the portion of the save file i am concerned with

<action actor="notepad01" length="3.59343886375" linearSpeed="2.9252011776" move="True" rotation="True" rotationSpeed="0.668617486954" speed="0.298489928246" time="2.47933340073"><waypoint orientation="(0.999999701977,-1.21343850523e-008,0.000749012979213,4.17166944544e-007)" position="(-5.82174968719,0.178779035807,21.498878479)" /><waypoint orientation="(0.989190459251,-7.62165370816e-007,-0.14663630724,9.9283624877e-008)" position="(3.39400339127,0.178777962923,21.3318519592)" /></action><action actor="notepad01" length="3.53890752792" linearSpeed="2.81926774979" move="True" rotation="True" rotationSpeed="0.644404053688" speed="0.287680387497" time="6.32812643051"><waypoint orientation="(0.989190459251,-7.62165655033e-007,-0.146636337042,9.9283624877e-008)" position="(3.39400339127,0.178777962923,21.3318519592)" /><waypoint orientation="(0.999248385429,2.56516131003e-007,-0.0387649200857,-8.24685457701e-008)" position="(-5.63284111023,0.178777962923,21.1489467621)" /></action>

i hope that using the HTML tags made it easier to see... somewhere in there are 2 'time' values corresponding to the pair of action tags

now, i want to repeat these two actions in sync with some cue points in a .cue file:

FILE "" WAVE
  TRACK 01 AUDIO
	TITLE "one"
	INDEX 01 00:00:00
  TRACK 02 AUDIO
	TITLE "two"
	INDEX 01 00:00:35
  TRACK 03 AUDIO
	TITLE "three"
	INDEX 01 00:00:70
  TRACK 04 AUDIO
	TITLE "four"
	INDEX 01 00:01:30

other than manually punching each of the time values into the XML, is there another way thats easier?

Edited by carmatic
Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

basically, what im asking for is if theres an editor which can add a line break between every bracket, and add indents for all the tags within a tag... so that i can see the structure without having to find where the tags begin and end...

Link to comment
Share on other sites

  • 0

On any UNIX/Linux/BSD system with LibXML you should have xmllint installed.

(me@home : ~/Desktop) $ xmllint --format test.xml

if you use Textmate it's wrapped used in the XML-bundle's Tidy command (Control+Shift+H).

Any text editor worth it's salt should have similar functionality built in.

Link to comment
Share on other sites

  • 0

Programmaticaly replace character ">" with ">\n"

Tabs will be a little more difficult -- a recursive xml parsing algorithm would do the trick.

Link to comment
Share on other sites

  • 0
Programmaticaly replace character ">" with ">\n"

i cant program ...

is there a way to use something like the 'replace' tool in editors, but somehow put the line break character into the 'replace with' box?

Edited by carmatic
Link to comment
Share on other sites

  • 0

i think ive solved it, kinda...

using notepad++, then using its search and replace in regular expression mode, i set to search for (>)(<) , and replace with \1\n\r\2

so it went from

post-61271-1244454642_thumb.jpg

to

post-61271-1244454790_thumb.jpg

and with an xml-specific tool (textfx --> html tidy --> re-indent xml), i get the indenting done too

post-61271-1244455312_thumb.jpg

i just thought i'd share this solution in case anyone else had to work with a single-line file like i did...

Edited by carmatic
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.