php - How to select child by name with DOMXpath? -
my current code is:
$dom = new domdocument(); $dom->loadxml($data); $xpath = new domxpath($dom); foreach ($dom->childnodes $node) { echo $node->nodename . "\n"; }
which outputs:
- xml-stylesheet
- #comment
- wsdl:definitions
is possible somehow (for example domxpath
) directly (without looping childnodes
name) xml-stylesheet
node?
example:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="../../../ver20/util/onvif-wsdl-viewer.xsl"?> <!-- copyright (c) 2008-2012 onvif: open network video interface forum. rights reserved. recipients of document may copy, distribute, publish, or display document long copyright notice, license , disclaimer retained copies of document. no license granted modify document. document provided "as is," , corporation , members , affiliates, make no representations or warranties, express or implied, including not limited to, warranties of merchantability, fitness particular purpose, non-infringement, or title; contents of document suitable purpose; or implementation of such contents not infringe patents, copyrights, trademarks or other rights. in no event corporation or members or affiliates liable direct, indirect, special, incidental, punitive or consequential damages, arising out of or relating use or distribution of document, whether or not (1) corporation, members or affiliates have been advised of possibility of such damages, or (2) such damages reasonably foreseeable, , arising out of or relating use or distribution of document. foregoing disclaimer , limitation on liability not apply to, invalidate, or limit representations , warranties made members , respective affiliates corporation , other members in written policies of corporation. --> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:trt="http://www.onvif.org/ver10/media/wsdl" targetnamespace="http://www.onvif.org/ver10/media/wsdl">
p.s. position in childnodes
not first.
Comments
Post a Comment