PHP通过DOM解析XML文件或者xml字符串
上一篇记录了php创建xml文档的过程,这篇将记录如何把接受到的xml字符串中的数据和属性值解析出来,以便进一步对数据进行处理。
xml文件
1. <?xml version="1.0" encoding="utf-8"?>
2. <data>
3. <time value="2011-08-01"/>
4. <time value="2011-08-02"/>
5. <time value="2011-08-03">
6. <worker name="test1" id="14">
7. <hour pid="6" pmid="3"><![CDATA[spot411]]></hour>
8. <hour pid="6" pmid="3"><![CDATA[spot411]]></hour>
9. </worker>
10. </time>
11. <time value="2011-08-04">
12. <worker name="test2" id="6">
13. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
14. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
15. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
16. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
17. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
18. <hour pid="9" pmid="4"><![CDATA[Pmlal]]></hour>
19. </worker>
20. </time>
21. <time value="2011-08-05">
22. <worker name="test3" id="1">
23. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
24. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
25. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
26. </worker>
27. <worker name="tony" id="2">
28. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
29. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
30. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
31. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
32. <hour pid="1" pmid="1"><![CDATA[Teasavant]]></hour>
33. </worker>
34. <worker name="test4" id="4">
35. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
36. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
37. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
38. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
39. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
40. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
41. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]></hour>
42. <hour pid="3" pmid="3"><![CDATA[Red8interactive]]><
相关新闻>>
- 发表评论
-
- 最新评论 更多>>