Hallo,
Ik krijg het maar niet voor elkaar om met SimpleXML de kinderen van een XML element terug te krijgen die binnen een namespace zitten en alleen maar attributen hebben.
Ik kan ze via xpath() wel direct terug krijgen, maar ik kom er niet bij via de parent met (children())
Ik will alle "message" attributen van elk operation command krijgen.. maar telkens als ik de operation opvraag via xpath krijg ik simplexml element zonder kinderen..
Ziet iemand wat ik verkeerd doe?
mijn code:
Ik krijg het maar niet voor elkaar om met SimpleXML de kinderen van een XML element terug te krijgen die binnen een namespace zitten en alleen maar attributen hebben.
Ik kan ze via xpath() wel direct terug krijgen, maar ik kom er niet bij via de parent met (children())
Ik will alle "message" attributen van elk operation command krijgen.. maar telkens als ik de operation opvraag via xpath krijg ik simplexml element zonder kinderen..
Ziet iemand wat ik verkeerd doe?
mijn code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
| <?php $data = '<?xml version="1.0" encoding="utf-8"?> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.w3.org/2001/XMLSchema" > <wsdl:portType name="qxqPortType"> <wsdl:operation name="SOAP_set"> <wsdl:input message="SetRequest"/> <wsdl:output message="SetResponse"/> </wsdl:operation> <wsdl:operation name="SOAP_get"> <wsdl:input message="GetRequest"/> <wsdl:output message="GetResponse"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions>'; echo '<pre>'; $xml = simplexml_load_string($data); if ($xml) { $res2 = $xml->xpath('//wsdl:portType/wsdl:operation'); //print_r($res); foreach ($res2 as $child2) { //print_r($child2->children()); echo 'child2'.PHP_EOL; print_r($child2->getName().PHP_EOL); print_r(count($child2->children()).PHP_EOL); print_r($child2); foreach ($child2->children() as $child3) { echo 'child3'.PHP_EOL; print_r($child3->getName().PHP_EOL); print_r(count($child3->children()).PHP_EOL); print_r($child3); foreach ($child3->children() as $child4) { echo 'child4'.PHP_EOL; print_r($child4->getName().PHP_EOL); print_r(count($child4->children()).PHP_EOL); print_r($child4); } } } } echo '</pre>'; ?> |