xsl-list
[Top] [All Lists]

Converting siblings into children

2005-11-04 13:48:43
I have a number of html files that I converted to xml using python.
Problem is that all the <p> tags are siblings. 

Given this:

<?xml version="1.0"?>
<html>
<body>
<p><a name="one"><b>1.1.1</b></a></p>
<p>1.1.1.1 </p>
<p>1.1.1.2 </p>
<p>1.1.1.3 </p>
<p>1.1.1.4 </p>
<p><a name="two"><b>1.1.2</b></a></p>
<p>1.1.2.1  </p>
<p>1.1.2.2 </p>
<p>1.1.2.3 </p>
<p>1.1.2.4 </p>
<p>1.1.2.5 </p>
<p>1.1.2.6 </p>
<p>1.1.2.7 </p>
<p>1.1.2.8 </p>
<p><a name="three"><b>1.1.3</b></a></p>
<p>1.1.3.1 </p>
<p>1.1.3.2 </p>
<p>1.1.3.3 </p>
<p>1.1.3.4 </p>
<p>1.1.3.5 </p>
<p>1.1.3.6 </p>
</body>
</html>

I need an output like this:

<p>
<a name="one"><b>1.1.1</b></a>
<p>1.1.1.1 </p>
<p>1.1.1.2 </p>
<p>1.1.1.3 </p>
<p>1.1.1.4 </p>
</p>

<p>
<a name="two"><b>1.1.2</b></a>
<p>1.1.2.1  </p>
<p>1.1.2.2 </p>
<p>1.1.2.3 </p>
<p>1.1.2.4 </p>
<p>1.1.2.5 </p>
<p>1.1.2.6 </p>
<p>1.1.2.7 </p>
<p>1.1.2.8 </p>
</p>

<p>
<a name="three"><b>1.1.3</b></a>
<p>1.1.3.1 </p>
<p>1.1.3.2 </p>
<p>1.1.3.3 </p>
<p>1.1.3.4 </p>
<p>1.1.3.5 </p>
<p>1.1.3.6 </p>
</p>

Any ideas?  Thanks in advance.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>