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.
<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);
精彩评论