1
가져 오기 전에 필터링해야하는 xml 내보내기가 있습니다.PHP 필터 XML xpath 및 내보내기 이미지
그래서로드하고 필터링하고 저장하는 코드를 작성했습니다.
$xml = simplexml_load_file('test.xml');
$nodes = $xml->xpath('/nodes/node[ ... condition ... ]');
$nodes->asXML('filtred.xml');
하지만 asXML()
가 SimpleXMLElement::function
이며, 그 SimpleXMLElement
요소의 목적은 것을 보았다.
일반 SimpleXMLElement
요소의 모든 $nodes
을 asXML()
에 그룹화하려면 어떻게해야하나요?
원래 XML 구조는 다음과 같습니다
<nodes>
<node>
<Titolo>Acquisti</Titolo>
<Corpo></Corpo>
<Nid>450</Nid>
</node>
...
</nodes>
내가 전화를 할 수있는 루트 요소에 의해 wraped되어야한다 내가 찾은이 http://stackoverflow.com/questions/3418019/simplexml-append-one-tree-to-another – cske
문제는 $ nodes는 배열이고 SimpleXMLElement 요소가 아니라는 것입니다. 그래서 나는 할 수 없다. 'importNode'또는 'appendChild'와 같은 SimpleXMLElement :: function을 사용하십시오. – Shyghar