The problem is I want to distinguish same elements name with different situation. For example:
<element>Hello StackOverFlow</element>
<element>
<group>
<ge>hello g1</ge>
<ge>hello g2</ge>
</group>
<group>
<ge>hello g3</ge>
<ge>hello g4</ge>
</group>
</element>
I want to have elements with text convert into
<div class="text_element">Hello StackOverFlow</div>
and for those elements with child nodes:
<div class="element">
<ul class="group">
<li>hello g1</li>
<li>hello g2</li>
</ul>
<ul class="group">
<li>hello g3</li>
<li>hello g4</li>
</ul>
</div>
So, the problem is how can I distinguish these two kind of elements in writing the template?
One simple way: write one template with match="element[normalize-space(text())]" and one with match="element[*]. The first matches element elements with text-node children that aren't just whitespace; the second matches element elements with element children.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With