I receive data in the following format from the server
<ul>
<li>Some text</li>
<li>Other text</li>
</ul>
Basically string containing a standard unordered list. What I want to do now is to remove the ul tags that wrap the list items, so that I would only receive the inner content. Like this:
<li>Some text</li>
<li>Other text</li>
It might be worth mentioning that ul tags will always be present when I get the data so I don’t realy care whats inside it, or are there any more ul tags nested within. I just need to remove the outer ones and get the data inside.
Either a JavaScript or PHP solution would be welcomed.
Note that
.firstChildwill only beulif there is no whitespace/text at the beginning of the string.In that case you could use:
instead