Xml indent problem

@

@cl

hello ,everybody

I'm a newer to xml,
and I need to format and indent xml in a textpanel,

as when input is
<root>
<node1>
<node11/>
</node1>
<node2/>
</root>

and need to put a button to format it ,let it shows like
<root>
<node1>
<node11/>
</node1>
<node2/>
</root>

I used the java1.5 and Eclipse platform , and not sure if I should use
the XSL .

regrads,
@CL
 
J

Joe Kesselman

Well, XSLT could be used, with a stylesheet that has its xsl:eek:utput
directive set to indent (and possibly additional implementation-specific
settings to say how much indentation to use; Xalan defaults to indenting
by 0, for historical reasons). Or you could hand-code a stylesheet to
track nesting depth and accomplish the same thing.

But I submit that you probably don't really want to do this. Changing
the indentation of XML risks changing the _MEANING_ of the XML, since
the indentation becomes part of the document's content.

What I would recommend, if you really want a tree view of your XML, is a
real XML viewer. There are many Java implementations thereof available;
it's quite easy for a Java hacker to make the standard Java tree views
run against a DOM back-end.
 
@

@cl

Well ,I see.
I don't really want to change the content of the xml file,
and just to find some nodes easily.
And I had found some tools to do it for me.

Best regards,
Richard

Joe Kesselman 写é“:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top