Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-20-2012, 01:42 AM   PM User | #1
ctrenks
New to the CF scene

 
Join Date: Feb 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
ctrenks is an unknown quantity at this point
Question DOMX get values in generic DIV inside names Div

OK, looking to extract data from html pages, I am currently trung DOMX to get elements from the HTML code but I am stuck with this..

EXAMPLE HTML :

Code:
<html>
<body>
<div id="page">
  <div id="header">
  HEADER ..
  </div>
<div id="content">
  <div id="item1">
    <div class="spacer">
      <div class="value">STUFF I WANT</div>
    </div>
  </div>
  <div id="item2">
    <div class="spacer">
      <div class="value">STUFF I DONT WANT</div>
    </div>
  </div>
  <div id="item3">
    <div class="spacer">
      <div class="value">STUFF I WANT</div>
    </div>
  </div>
  <div id="item4">
    <div class="spacer">
      <div class="value">STUFF I WANT</div>
    </div>
  </div>
 </div>
</div>
</body>
</html>
So with DOMX its easy to grab a named DIV content, or even a class, but having multiple divs with the same class name wont help.

I would like to grab somthing like this

Code:
$elements = $xpath->query('//*[contains(@class, \'item1\')]');
but do into the "spacer" div then into the "value" div. So I specify the named parent div then drill into two generic div's for the results I really want.

I havent found a good example of this anywhere yet

Thanks,
Chris
ctrenks is offline   Reply With Quote
Reply

Bookmarks

Tags
domx

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:54 PM.


Advertisement
Log in to turn off these ads.