Demonic Posted August 4, 2008 Share Posted August 4, 2008 Alight I got like 4 tables in this BIG XHTML file but I want to some how skip all the hard parts and gets straight to the tables they are something like this: [table] => Array ( [0] => SimpleXMLElement Object ( [@attributes] => Array ( [class] => tbl_profile [id] => table1 ) Each table has an id attribute with a unique 'table#' is it possible to use http://us.php.net/manual/en/function.simplexml-element-xpath.php and get straight to the table without anywork? And how lol xpath isn't my thing. Thanks, its for this signature thing I'm trying to make dynamic signatures. Link to comment https://forums.phpfreaks.com/topic/118119-solved-simple-xml-and-xpath-have-the-slightest-idea/ Share on other sites More sharing options...
Demonic Posted August 4, 2008 Author Share Posted August 4, 2008 Okay I've sorted the above by cheating with DOM and importing it into Simple XML: Array ( [0] => SimpleXMLElement Object ( [strong] => 1713 [comment] => SimpleXMLElement Object ( ) ) [1] => SimpleXMLElement Object ( [strong] => 1216 [comment] => SimpleXMLElement Object ( ) ) [2] => SimpleXMLElement Object ( [strong] => 147 [comment] => SimpleXMLElement Object ( ) ) [3] => SimpleXMLElement Object ( [0] => 150 ) [4] => SimpleXMLElement Object ( [strong] => 68 [comment] => SimpleXMLElement Object ( ) ) [5] => SimpleXMLElement Object ( [0] => 37 ) [6] => SimpleXMLElement Object ( [strong] => 45 [comment] => SimpleXMLElement Object ( ) ) [7] => SimpleXMLElement Object ( [0] => 11.42 ) [8] => SimpleXMLElement Object ( [0] => 8.11 ) [9] => SimpleXMLElement Object ( [0] => 9 ) ) Alright I have all the td's I need with the below data: <?php $profile = "Oopz"; $profile_url = "http://combatarms.nexon.net/Community/Profile.aspx?user="; $main_profile = $profile_url . $profile; $doc = new DOMDocument(); $doc->loadHTML( file_get_contents( $main_profile ) ); $x = $doc->getElementById("table1"); $s = simplexml_import_dom($x); $data1 = $s->xpath('tr/td'); print_r($data1); ?> But I need to get each value, stripping all inner tags, I tried doing: $s->xpath('tr/td/*') but I only got results that had "strong" tags. XPath is hard -.- Link to comment https://forums.phpfreaks.com/topic/118119-solved-simple-xml-and-xpath-have-the-slightest-idea/#findComment-607749 Share on other sites More sharing options...
Demonic Posted August 4, 2008 Author Share Posted August 4, 2008 Aight nvm forums real "helpful" while(list( , $node) = each($data1)) { //echo $node[0] . '<br>'; //echo $node[0]->strong . '<br>'; if( $node[0]->strong ) { echo $node[0]->strong . '<br>'; } else if( $node[0] ) { echo $node[0] . '<br>'; } } Got it sorted Link to comment https://forums.phpfreaks.com/topic/118119-solved-simple-xml-and-xpath-have-the-slightest-idea/#findComment-607758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.