PHP를 통해 REST XML 파일에서 메소드를 얻고 싶습니다. 나는이 형식으로되어있는 지역 REST 파일이 :REST 호출에서 메소드 가져 오기
SimpleXMLElement Object
(
[doc] => SimpleXMLElement Object
(
)
[resources] => SimpleXMLElement Object
(
[@attributes] => Array
(
[base] => https://**url**
)
[resource] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[path] => xml/{accesskey}/project
)
[param] => SimpleXMLElement Object
(
[@attributes] => Array
(
[name] => accesskey
[style] => template
[type] => xs:string
)
)
[method] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => getAllProjects
[name] => GET
)
[response] => SimpleXMLElement Object
(
[representation] => SimpleXMLElement Object
(
[@attributes] => Array
(
[mediaType] => application/xml; charset=utf-8
)
)
)
)
... and so on
나는 다음과 같은 코드를 가지고 있지만, 그것은 단지 첫 번째 방법 이름 반환
$file="application.wadl";
$xml = simplexml_load_file($file);
foreach($xml->resources[0]->resource->method->attributes() as $a => $b) {
echo $b,"\n";
}
내가 그들 모두를 추출하고 싶습니다를 , 단지 첫 번째 것이 아닙니다. 그렇게하는 방법?
첫 번째 ID를 반환합니다. [여기] (http://pastebin.com/0EeEyqTU)는 전체 XML 파일이므로 이전에 게시하지 않았습니다. "getProjectSystems"와 같은 다른 ID가 있습니다. – Kokesh
@Kokesh 그'print_r'에서 XML 구조를 읽는 것은 꽤 어렵습니다. 실제 XML 샘플을 게시 할 수 있습니까? 기억해야 할 중요한 점은 위의 코드가 * first *'resource'의 모든 메소드 노드를 반복한다는 것입니다. 그것은 여러개의'resource' 노드를 반복하지 않거나 XML의 다른 곳에서'method' 노드를 재귀 적으로 찾습니다. – IMSoP
죄송합니다. 지금 당장 XML을 업로드하는 것에 대해 생각해 봤습니다. [here is] (http://pastebin.com/N4nSQXy8) – Kokesh