Reformat xml (html) function

Discussion Forums discussion Reformat xml (html) function

This topic contains 5 replies, has 3 voices, and was last updated by  horus 1 year, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
January 29, 2013 at 2:04 pm #19644


Since there is no search function in this new version of forum, sorry that I have to ask this question:

Is there a function (or addon) to reformat xml strings? For example, I have an xml element like this:

I would like a function to reformat it nicely and output something like:


February 1, 2013 at 2:45 pm #19646


My example was badly formatted…. so let’s me write the xml again using [ and ]

[a]aaaa[b]bbbb[/b][c attrib="cccc" /][/a]

[c attrib="cccc" /]

February 4, 2013 at 10:14 pm #19648


Not sure if it’s a great solution, but I would just use find replace allowing backslash expressions, eg:
first find: ] replace: ]\n, second find: [ replace: \n[
then use find: ^\n replace: (nothing) to remove any blank lines.

There’s a magnifying glass in top right for search, but it seems broken. Just use google to search

February 5, 2013 at 9:52 am #19649


As a matter of fact, I’m already using the method you mentioned as a temporary incomplete workaround.

The problem with this method is that there is no indentation and you can’t easily see the level. (In my second post, I had put in some spaces but WordPress removed them all!)

February 6, 2013 at 9:34 pm #19653

Key Master

I normally use HTML Tidy to do this job for me. See the docs site for configuration:

February 7, 2013 at 4:26 pm #19657



OK, if my guess is correct, I have to search “HTML Tidy” in Google and download the “tidy.exe” from their website.

Could you make the words “HTML tidy” into a hyperlink to point to please?

However, I’m unable to reformat xml string as suggested by that webpage of yours. I got these errors:
HTML Tidy: unknown option: w
HTML Tidy: unknown option: l
Error: Can’t open “CRLF”
Error: Can’t open “–tab-size”
Error: Can’t open “4″

I listed out tidy.exe options and it seems that “-newline” and “–tab-size” are not options. Something has changed?

Moreover, it took me some time to figure out what I was supposed to do! Maybe a little bit more explanation in that page is preferable.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.