Re: Xml indent problem



Well, XSLT could be used, with a stylesheet that has its xsl:output 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.
.



Relevant Pages

  • Re: Creating an XML document ?
    ... Trying to get the indentation right by ... runtime code that "prints" the tabs one way or another. ... where make_tabs returns a string of tabs. ... The other option you've got is perhaps generate the xml without any ...
    (comp.lang.c)
  • Create xml with formatting
    ... node has some innertext as well as child nodes. ... I make xml like this the indentation is lost. ...
    (microsoft.public.dotnet.general)
  • Re: CrLf in XML ?
    ... and indentation is mainly to make things easier for human readers. ... However, the XML ... be clearly a one-line long string. ... Is there a way to tell the DOMDocument object to generate the latter? ...
    (microsoft.public.access.externaldata)
  • Re: Create xml with formatting
    ... node has some innertext as well as child nodes. ... > I make xml like this the indentation is lost. ... > then the entire node is written in a single line, without indentation. ...
    (microsoft.public.dotnet.general)
  • Re: How to indent a line after

    ... I'm attached to the idea of keeping content separate from formatting ... making a stylesheet for it. ... kind of indentation between blocks is not so convenient. ... but indent the first character of the next line". ...
    (alt.html)