I have this kind of xml where some <li> tags doesn't have <ol>/<ul> as it's parent. Need to add as it's parent.
Example:
<root>
<p>some text</p>
<ol>
<li>
<a href="http://cowherd.com" rel="nofollow">http://cowherd.com</a>
</li>
</ol>
<li>some text</li>
<li>some text</li>
<p>some more text</p>
<li>some text in li.</li>
<p>some more text</p>
<li>some text in li.</li>
</root>
Desired Output: I want to add a parent <ol>or<ul> tag to those <li>tags which don't have it's parent as <ol>/<ul>. And also if there are continuesly more than one <li> tag then all the <li> tags should come under same <ul>/<ol>just like below. Thanks in advance.
<root>
<p>some text</p>
<ol>
<li>
<a href="http://cowherd.com" rel="nofollow">http://cowherd.com</a>
</li>
</ol>
<ol>
<li>some text</li>
<li>some text</li>
</ol>
<p>some more text</p>
<ol>
<li>some text in li.</li>
</ol>
<p>some more text</p>
<ol>
<li>some text in li.</li>
</ol>
</root>