考慮以下XML片段XML的幫助。需要提取XML節點的文本和子節點(PHP)
<s1>
S1 Tag: s1 content 1
<test1>Test1 Tag: content</test1>
S1 Tag: s1 content 2
<test2>Test2 Tag: content</test2>
S1 Tag: s1 content 3
</s1>
我想提取<s1>
標籤文本(S1標籤:S1內容1,S1標籤:S1內容2,S1標籤:S1內容3)及其所有子標籤(<test1>
和<test2>
)以及其內容(Test1標籤:內容,Test2標籤:內容)。
輸出可以是任何格式例如(最後我必須堅持它在DB和將檢索再次產生相同的XML)
S1 tag: S1 Tag: s1 content 1
test1 tag: Test1 Tag: content
S1 Tag: s1 content 2
test2 tag: Test2 Tag: content
S1 Tag: s1 content 3
所以很多教程谷歌搜索的時候'PHP解析XML tutorial' ... [PHP的最佳XML分析器(的 – 2012-02-24 17:32:46
可能重複http://stackoverflow.com/questions/188414/best-xml-parser-for-php ) – 2012-02-24 17:35:59