开发者

PHP XML DOM getElementById

I need to pick one tag from xml file and insert another tag before this tag. I'm doing this with method insertBefore in DOM, but the problem is, that if I want pick the tag before I want to add the another tag by method getElementById, it doesn't work.

It writes "using non-object". This is how the tag looks:

<item id="Flow_0" href="Flow_0.html" media-type="application/xhtml+xml"/>

Somewhere I read that it must look like this, but I can't edit all files:

<item xml:id="Flow_0" href="F开发者_Go百科low_0.html" media-type="application/xhtml+xml"/>

Have you got any idea how to do that?


A common workaround is to use XPath to get the element.

$item = $xpath->query('//item[@id="Flow_0"]')->item(0);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜