![]() |
|
|
|
#1 |
|
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 @cl |
|
|
|
|
#2 |
|
Posts: n/a
|
Well, XSLT could be used, with a stylesheet that has its xsl
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. |
|
|
|
#3 |
|
Posts: n/a
|
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 写é“: > 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. |
|