开发者

PHP: How to get all tags inside certain tag in XML by means of DOM extension

开发者 https://www.devze.com 2023-03-07 07:58 出处:网络
I have XML <myelement> <oneelement>val1</<oneelement> <notknown>val2</n开发者_StackOverflow社区otknown>

I have XML

<myelement>
    <oneelement>val1</<oneelement>
    <notknown>val2</n开发者_StackOverflow社区otknown>
    <notknown2>val3</notknown2>
</myelement>

and I parse it. I get one xml-tag:

$myelement=$reask->getElementsByTagName('myelement')->item(0)

Now I want get all tags inside $myelement even I don't know their names. How could I do this if I use DOM extension of PHP5?

Thanks for help.


Use the childNodes property of $myelement as described in the manual:

$childrenOfmyelement = $myelement->childNodes;
0

精彩评论

暂无评论...
验证码 换一张
取 消