doulangdang9986 2010-10-14 21:08
浏览 36

在PHP中存储复杂的XML值

Consider this hypothetical xml:

<myApi xmlns="urn:something" xmlns:bla="urn:hello">
  <argument1>foo</argument1>
  <argument2>
     <p xmlns="http://www.w3.org/1999/xhtml">Some paragraph of text. <img src="http://www.example.org/hello.png" bla:test="oi" /></p>
  </argument2>
</myApi>

What would be the best way in PHP to parse out the 2nd argument. The full xml-structure must be stored in the database, but consideration has to be made for the fact that it could reference already-declared xml namespaces higher up in the document.

Is there a good way to take out a chunk of XML using any of the readily available PHP parsing libraries, and store all the semantic information?

  • 写回答

1条回答 默认 最新

  • duan051347 2010-10-14 22:39
    关注

    Have you looked at SimpleXML? It does parsing without validating, so you can throw any well-formed XML at it and sort out the valid and invalid tags yourself. You can also pull out XML fragments at any level. The only thing it struggles a little with is namespaces.

    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题