0

I have html like this:

<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. By going through related questions, I learnt that it can be done using DOMXPath (if i'm not wrong). I read several other examples about using DOMXPath but could not get any clue for query.

Any help appreciated.

Thanks and Regards

Chandra

1 Answers1

0

Please check THIS wonderful stackoverflow page. I think it will help you to solve your problem. Basically, querypath and phpquery this 2 tool can help you. For more reference check that article please.

Community
  • 1
  • 1
enam
  • 1,179
  • 1
  • 10
  • 24
  • I m sorry. That was not my requirement! I need to store the HTML content into an array. – Chandra Jan 27 '11 at 16:18
  • 1
    I'm soory,too. I think regular expression can solve your problem also. For example if you use preg_match_all("/(.*)<\/b>/U", $str, $bold); here $str is your string(Your HTML input) and $bold will be an array which contain all the ..... Similarly other pattern can be easily build. For more information please check the php manual. – enam Jan 27 '11 at 18:13