473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to pretty-print XML with a regular expression?

Here's a challenge for all the hard-core regexp writers out there:
pretty-printing XML in as few regular expressions as possible.
Basically what I'm looking for is a method of converting this:

<tag1 attr="value"><tag2 earth="round"><tag3
bob="youruncle"></tag3><tag4 perl="cool" /></tag2></tag1>

into this:

<tag1 attr="value">
<tag2 earth="round">
<tag3 bob="youruncle">
</tag3>
<tag4 perl="cool" />
</tag2>
</tag1>

with as little code as possible. Thanks!
Jul 19 '05 #1
0 2115

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: edw | last post by:
All, I got following question. I want to sort a XML files content in following manner: Source file: <btag> <bbtag key=val/> <abtag key=val/> </btag>
4
by: jmm-list-gn | last post by:
Hello, Most XML examples have the content neatly laid out with newlines and indenting. A DOM parser, however, does not bother with such niceties when creating an XML file. Is there a "pretty...
354
by: Montrose... | last post by:
After working in c# for a year, the only conclusion I can come to is that I wish I knew c. All I need is Linux, the gnu c compiler and I can do anything. Web services are just open sockets...
39
by: George Hester | last post by:
How do they do it? http://home.nycap.rr.com/foryorisonly/spoof.htm It doesn't matter where the browser is when opened. But if the browser is minimazed then it jumps to (0,0) of the screen. ...
0
by: Kalle Anke | last post by:
Does a Java "pretty formatter" exist? I would like to use a Python based web building tool but would like to pretty format Java code (for example adding color to keywords, etc). I haven't...
8
by: Susan Bricker | last post by:
Is there a way to change the background color of command buttons? I know that I saw some VBA code somewhere that showed how to do this. I think it involved making the button transparent and then...
6
by: John Wood | last post by:
Does anyone know of a good, free C# pretty-printer? One that outputs to HTML would be good. If it came with C# source it would be even better.
3
by: Jon Pope | last post by:
I've got an XML stream <node1><node2></node2></node1> which I would like to "pretty" up so it looks like the following: <node1> <node2> </node2> </node1> I've investigated the...
1
by: Johnny Jörgensen | last post by:
I've got a serious problem. I've got Visual Studio 2005 installed, and of course I'm using the Pretty Listing formatting function. When I start up VS, everything is fine, but after a while (which...
0
by: Pretty nice site, wants to see much more on it!,Pr | last post by:
Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!,Pretty nice site, wants to see much more on it!
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.