xPath problem matching specific attribute

Sn1p3rGT

New Member
I've got the following HTML that I am trying to pull the state attribute out of.\[code\]<div id="content" class="listing mapListing" longitude="123.0000" latitude="-123.0000" listingName="business" business=";12345678;;;;evar01=name" state="NSW" events="1">\[/code\]I'm trying to match using the following PHP, which doesn't return "NSW".\[code\]$xpath = new DomXPath($html); foreach ($xpath->query("//div[@id='content']") as $item) { echo $item->getAttribute("state"); }\[/code\]However, the following; returns "listing" (instead of "listing mapListing") and my suspicion is the space is causing issues\[code\]$xpath = new DomXPath($html); foreach ($xpath->query("//div[@id='content']") as $item) { echo $item->getAttribute("class"); }\[/code\]Does anyone have any suggestions on how I can match against "state" attribute?
 
Back
Top