How do I parse HTML non-class items in PHP?

                    <div id="dump-list">    
<div class="dump-row"> 
 <div class="dump-location odd" data-jmapping="{id: 35, point: {lng: -73.00898601, lat: 41.71727402}, category: 'office'}">

    <div class="SingleLinkNoTx">
    <a href="#10" class="loc-link">Acme Software</a><br/><strong>John Doe, MBA</strong><br/>123 Main St.<br />New York, NY 10036<br /><strong class="telephone">(212) 555-1234</strong><br/>
    </div><!-- END.SingleLinkNoTx -->

    <a href="http://www.example.com" target="_blank" class="web_link">Visit Website</a><span><br />(0.3 miles)</span>   
    <div class="loc-info">
             <div class="loc-info-text ">
        John Doe, MBA<br /><a href="http://maps.google.com/?daddr=41.71727402,-73.00898601" target="_blank">Get Directions &raquo;</a>    
         </div>

    </div>

</div>

How is the above HTML parsed in PHP, so that non-class fields such as the company name, person's name (John Doe, MBA), address, city, state zip code can be separated to their own variable using xpath? Thanks!

Answers


Something among the lines of:

$xpath->evaluate('//a[@class="loc-link"]//text()');

$xpath is the xpath object with all the dom information, you can read more about it here. The evaluate function returns the content for the requested expression.

The expression //a[@class="loc-link"]//text() tell xpath to look for any anchor a with the class attribute set to loc-link then within the anchor look for any (nested) textnode.


Need Your Help

Internet Explorer and jQuery issues

javascript jquery internet-explorer

I have a script that works in Firefox, Safari, and Chrome. It just doesn't work in Internet Explorer for whatever reason. The code is fairly simple:

What causes “fatal: The remote end hung up unxepctedly” when using git to try and clone a repository on github?

git github

I'm trying to clone the facebook iOS API located on github.com. I'm new to git and I've just downloaded the git client. I also have created a github account. I thought I configured everything corre...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.