简体   繁体   English

使用DOMXPath解析php html

[英]php html parsing using DOMXPath

I have html like this: 我有这样的HTML:

 <span><b>Company: </b> Nirmal Datacomm Pvt Ltd<br> <b>location: </b> Mumbai<br> <b>Ref: </b> 8560918<br> </span> 

I want to extract the bold text and the text immediately following it into an array like the following: 我想将粗体文本和紧随其后的文本提取到如下数组中:

array('company'=>'Nirmal DataComm Pvt Ltd','location'=>'Mumbai','ref'=>'8560918')

I am new to PHP. 我是PHP新手。 By going through related questions, I learnt that it can be done using DOMXPath (if i'm not wrong). 通过研究相关问题,我了解到可以使用DOMXPath来完成(如果我没有记错的话)。 I read several other examples about using DOMXPath but could not get any clue for query. 我阅读了有关使用DOMXPath的其他几个示例,但无法获得任何查询线索。

Any help appreciated. 任何帮助表示赞赏。

Thanks and Regards 谢谢并恭祝安康

Chandra 钱德拉

Please check THIS wonderful stackoverflow page. 请检查精彩的stackoverflow页面。 I think it will help you to solve your problem. 我认为这将帮助您解决问题。 Basically, querypath and phpquery this 2 tool can help you. 基本上, querypathphpquery这2个工具可以为您提供帮助。 For more reference check that article please. 有关更多参考,请查看该文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM