PHP 对象的 XPath 结果
我有一个 xml 文件,它代表许多对象,我在应用程序中有一个类。例如,博客文章:
<blogposts>
<blogpost id="604">
<title>afdghadfh</title>
<body>adfgadfgda</body>
</blogpost>
<blogpost id="605">
<title>dafghadh</title>
<body>afadf</body>
</blogpost>
</blogposts>
我想使用 XPath 读取 xml 文件并将结果转换为博客文章对象。是否有任何简单的方法可以将生成的 SimpleXMLElement 对象转换为 blogpost 对象的值?
任何建议表示赞赏。
谢谢。
I have an xml file which represents a number of objects for which I have a class in my application. For example, blogposts:
<blogposts>
<blogpost id="604">
<title>afdghadfh</title>
<body>adfgadfgda</body>
</blogpost>
<blogpost id="605">
<title>dafghadh</title>
<body>afadf</body>
</blogpost>
</blogposts>
I would like to read the xml file using XPath and convert the results to blogpost objects. Is there any simple way to convert the resulting SimpleXMLElement Objects into values for a blogpost object?
Any advice appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据需要进行调整。
Tweak as needed.