PHP - Parsing An Array
Hi,
Need help in parsing the . I am new to php and need to parsing and print only few elements in the arrary I have an array as below: Array ( [@attributes] => Array ( [WARRANTYCATEGORY] => Customer Warranty [NA_RATING] => [TAGCATEGORY1] => [TAGCATEGORY1DESC] => [TAGCATEGORY2] => [RESPONSEDATE] => 08-14-2006 04:40:40 PM [CASEID] => 1435435 [DUTYMANAGERAPPROVALTEXT] => [COUNTER] => 0 [DESCRIPTION] => SPRLSL:Cluster Notification [NA_BUGNO] => [PRIORITY] => 3 [WARRANTYPRODUCT] => WARR36MTH_HW_DISK [NA_DISRUPTION_EVENT] => [SERIALNUMBER] => 123456789 [NADUPCASEID] => [DMGERAPPRL] => [SYSNAME] => REWSRAPP34 [DATECLOSED] => 08-17-2006 04:47:37 PM [CASE_STATUSTEXT] => Closed [NASUPPORTOFFERING] => ST [CREATEDBY] => ) ) I need to access only CASEI D, CASE_STATUSTEXT and DATECLOSED from the above array How can I access that ? Thanks and Regards, Usha Similar TutorialsI have a situation were I need to just get a simple location. I don't want any while loops or any of that jazz. I just want 1 string location every time. <?php $ider = $_GET['id']; $conn = mysqli_connect("localhost", "Me", "pass", "MyDB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT Location FROM LifeSaver1 WHERE id =$ider"; $result = $conn->query($sql); $obj = mysqli_fetch_object($result); $obj2 = $obj->Location; var_dump($obj); ?> This is what it outputs Quotestring(11) "Boston" I just need Boston. Can anyone give me a hint? Folks, I want to parse a particular element from an array and nothing else. Here is the Class (RecursiveTwitterSearch.php): <? /** * Wrapper class around the Twitter Search API for PHP * Based on the class originally developed by David Billingham * and accessible at http://twitter.slawcup.com/twitter.class.phps * @author Ryan Faerman <ryan.faerman@gmail.com> * @version 0.2 * @package PHPTwitterSearch */ class TwitterSearch { /** * Can be set to JSON (requires PHP 5.2 or the json pecl module) or XML - json|xml * @var string */ var $type = 'json'; /** * It is unclear if Twitter header preferences are standardized, but I would suggest using them. * More discussion at http://tinyurl.com/3xtx66 * @var array */ var $headers=array('X-Twitter-Client: PHPTwitterSearch','X-Twitter-Client-Version: 0.1','X-Twitter-Client-URL: http://ryanfaerman.com/twittersearch'); /** * Recommend setting a user-agent so Twitter knows how to contact you inc case of abuse. Include your email * @var string */ var $user_agent=''; /** * @var string */ var $query=''; /** * @var array */ var $responseInfo=array(); /** * Use an ISO language code. en, de... * @var string */ var $lang; /** * The number of tweets to return per page, max 100 * @var int */ var $rpp; /** * The page number to return, up to a max of roughly 1500 results * @var int */ var $page; /** * Return tweets with a status id greater than the since value * @var int */ var $since; /** * Returns tweets by users located within a given radius of the given latitude/longitude, where the user's location is taken from their Twitter profile. The parameter value is specified by "latitide,longitude,radius", where radius units must be specified as either "mi" (miles) or "km" (kilometers) * @var string */ var $geocode; /** * When "true", adds "<user>:" to the beginning of the tweet. This is useful for readers that do not display Atom's author field. The default is "false" * @var boolean */ var $show_user = false; /** * @param string $query optional */ function TwitterSearch($query=false) { $this->query = $query; } /** * Find tweets from a user * @param string $user required * @return object */ function from($user) { $this->query .= ' from:'.str_replace('@', '', $user); return $this; } /** * Find tweets to a user * @param string $user required * @return object */ function to($user) { $this->query .= ' to:'.str_replace('@', '', $user); return $this; } /** * Find tweets referencing a user * @param string $user required * @return object */ function about($user) { $this->query .= ' @'.str_replace('@', '', $user); return $this; } /** * Find tweets containing a hashtag * @param string $user required * @return object */ function with($hashtag) { $this->query .= ' #'.str_replace('#', '', $hashtag); return $this; } /** * Find tweets containing a word * @param string $user required * @return object */ function contains($word) { $this->query .= ' '.$word; return $this; } /** * Set show_user to true * @return object */ function show_user() { $this->show_user = true; return $this; } /** * @param int $since_id required * @return object */ function since($since_id) { $this->since = $since_id; return $this; } /** * @param int $language required * @return object */ function lang($language) { $this->lang = $language; return $this; } /** * @param int $n required * @return object */ function rpp($n) { $this->rpp = $n; return $this; } /** * @param int $n required * @return object */ function page($n) { $this->page = $n; return $this; } /** * @param float $lat required. lattitude * @param float $long required. longitude * @param int $radius required. * @param string optional. mi|km * @return object */ function geocode($lat, $long, $radius, $units='mi') { $this->geocode = $lat.','.$long.','.$radius.$units; return $this; } /** * Build and perform the query, return the results. * @param $reset_query boolean optional. * @return object */ function results($reset_query=true) { $request = 'http://search.twitter.com/search.'.$this->type; $request .= '?q='.urlencode($this->query); if(isset($this->rpp)) { $request .= '&rpp='.$this->rpp; } if(isset($this->page)) { $request .= '&page='.$this->page; } if(isset($this->lang)) { $request .= '&lang='.$this->lang; } if(isset($this->since)) { $request .= '&since_id='.$this->since; } if($this->show_user) { $request .= '&show_user=true'; } if(isset($this->geocode)) { $request .= '&geocode='.$this->geocode; } if($reset_query) { $this->query = ''; } return $this->objectify($this->process($request))->results; } /** * Returns the top ten queries that are currently trending on Twitter. * @return object */ function trends() { $request = 'http://search.twitter.com/trends.json'; return $this->objectify($this->process($request)); } /** * Internal function where all the juicy curl fun takes place * this should not be called by anything external unless you are * doing something else completely then knock youself out. * @access private * @param string $url Required. API URL to request * @param string $postargs Optional. Urlencoded query string to append to the $url */ function process($url, $postargs=false) { $ch = curl_init($url); if($postargs !== false) { curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postargs); } curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $this->user_agent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers); $response = curl_exec($ch); $this->responseInfo=curl_getinfo($ch); curl_close($ch); if( intval( $this->responseInfo['http_code'] ) == 200 ) return $response; else return false; } /** * Function to prepare data for return to client * @access private * @param string $data */ function objectify($data) { if( $this->type == 'json' ) return (object) json_decode($data); else if( $this->type == 'xml' ) { if( function_exists('simplexml_load_string') ) { $obj = simplexml_load_string( $data ); $statuses = array(); foreach( $obj->status as $status ) { $statuses[] = $status; } return (object) $statuses; } else { return $out; } } else return false; } } class RecursiveTwitterSearch extends TwitterSearch { var $request_count = 0; var $max_request_count = 5; var $max_id; function recursive_results() { $request = 'http://search.twitter.com/search.'.$this->type; $request .= '?q='.urlencode($this->query); if(isset($this->rpp)) { $request .= '&rpp='.$this->rpp; } if(isset($this->page)) { $request .= '&page='.$this->page; } if(isset($this->lang)) { $request .= '?='.$this->lang; } if(isset($this->since)) { $request .= '&since_id='.$this->since; } if($this->show_user) { $request .= '&show_user=true'; } if(isset($this->geocode)) { $request .= '&geocode='.$this->geocode; } if(isset($this->max_id)) { $request .= '&max_id='.$this->max_id; } $response = $this->objectify($this->process($request)); $this->request_count++; if ($response) { $results = $response->results; if(!empty($response->next_page)) { preg_match('|\?page=([0-9]*)&max_id=([0-9]*)&|', $response->next_page, $matches); $this->page = $matches[1]; $this->max_id = $matches[2]; if ($this->request_count < $this->max_request_count) { $results = array_merge($results, $this->recursive_results()); } } return $results; } else return false; } function max_request_count($n) { $this->max_request_count = $n; return $this; } } ?> Here is how i am calling it: <?php require ("RecursiveTwitterSearch.php"); $rts = new RecursiveTwitterSearch('paintball mask'); echo '<pre>'; print_r($rts->recursive_results()); echo '</pre>'; echo 'It took ' . $rts->request_count . ' request(s) to get this result.'; ?> If you observer the Output, u will see lot of array, i want to extract only "[text]" portion. So the desired output should be like: Quote vPaintball Mask http://bit.ly/czBA6S The Paintball Republic does a short video about mask safety. LEARN. http://fb.me/KkMvjDWF airsoft vs paintball mask http://goo.gl/fb/tyoxk @mmorgansmithh like wearing a paintball mask on your head to starbucks Tippmann US Army Ranger Paintball Goggle Mask - Camo: Tippmann US Army Ranger Paintball Goggle Mask - Camo ... http://bit.ly/9hFi3p and so on......... Infact, i prfer to use "foreach" to each each element so i can do further operation on it. Can anyone help to achieve this? Natty i am trying to get values from the json array that get direct messages from twitter but i am getting the message error "Parse error: syntax error, unexpected T_AS, expecting '(' " in relation to the line "foreach (array as $direct_message) {" Also should i convert the array into a linear php array? Code: [Select] // create new instance $OAuth = new TwitterOAuth($consumer_key,$consumer_secret, $oAuthToken, $oAuthSecret); $direct_message = $OAuth->get('https://api.twitter.com/1/direct_messages.json?count=1&page='); function write_into_database ($direct_message) { $conn = mysql_connect("127.0.0.1", "Diego", "frafra") or die(mysql_error()); mysql_select_db('bot', $conn) or die(mysql_error()); foreach(array as $direct_message) { mysql_query("INSERT INTO 'followers' ('user_id', 'user_alias'), VALUES ('{$direct_message->sender_id}', '{$direct_message->sender_screen_name}, INSERT INTO 'd_messages'('message_id', 'message'), VALUES ('{$direct_message->id}' ,'{$direct_message->text})"); } write_into_database($direct_message); I have the following code below: hi. Basically, I am trying to set up a random bible verse script. I found an rss/xml feed he http://www.mybiblescripture.com/rss/bible.php?fmt=daily&trans=KJV Using the following code, I am attempting to parse the feed in to an array: Code: [Select] <?php function fetchXML($url) { //initialize library $ch = curl_init(); //used to make us look like a browser $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; //set the url curl_setopt ($ch, CURLOPT_URL, $url); //set that I want to wait for a response curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //make us look like a web browser curl_setopt ($ch, CURLOPT_USERAGENT, $useragent); //get data $data = curl_exec($ch); //clean up curl_close($ch); //return xml data return $data; } define("USE_CURL", true); $url = "http://www.mybiblescripture.com/rss/bible.php?fmt=daily&trans=KJV"; //get xml doc with info $data = fetchXML($url); //create a SimpleXML object to parse the xml $char_xml = new SimpleXmlElement($data); echo print_r($char_xml); ?> Which gives me the following output: Code: [Select] SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => My Bible Scripture - Bible Verse of the Day (KJV) [link] => http://www.mybiblescripture.com/ [description] => Verse of the Day - King James Version [language] => en-us [pubDate] => SimpleXMLElement Object ( ) [generator] => CPG-Nuke Dragonfly [copyright] => My Bible Scripture [category] => Religion [image] => SimpleXMLElement Object ( [width] => 111 [height] => 40 [url] => http://www.mybiblescripture.com/images/logo.gif [title] => My Bible Scripture [link] => http://www.mybiblescripture.com/ ) [item] => Array ( [0] => SimpleXMLElement Object ( [title] => Corinthians I 10:17 [link] => http://www.mybiblescripture.com/Bible/l_op=view-verse/lid=29613/trans=KJV.html [description] => For we being many are one bread, and one body: for we are all partakers of that one bread. (KJV) [pubDate] => SimpleXMLElement Object ( ) ) [1] => SimpleXMLElement Object ( [title] => Bible Verses [link] => http://www.mybiblescripture.com [description] => Find more Bible Scripture [pubDate] => Fri, 11 Mar 2011 00:45:06 GMT ) ) ) ) 1 What I am trying to do is pull ONLY [title] => Corinthians I 10:17 and its accompanying verse [description] => For we being many are one bread, and one body: for we are all partakers of that one bread. (KJV). I am very bad at trying to read multi-dim arrays and can't for the life of me figure out how to print the aforementioned keys. Could anyone help me here? thanks I'm trying to go through a document and replace all the UBB tags with different values. I can preg match the tags, but I don't quit remember how to do the replacement. Tags are like: ect. Anyone have a basic example I can go from? I know I've done it before, just can't think tonight. Hi guys I am new to this forum and a complete newb to php. I was wandering if I can get some help with XML parsing using php. The XML snippet is as follows:-- <some-xml1> <some-xml2> </some-xml2> <ReportHost> <HostName>192.168.2.34</HostName> <startTime>Thu Dec 17 13:58:49 2007</startTime> <stopTime>Thu Dec 17 15:13:13 2007</stopTime> <netbios_name>(unknown)</netbios_name> <mac_addr>(unknown)</mac_addr> <dns_name>(unknown)</dns_name> <os_name>(unknown)</os_name> <num_ports>2</num_ports> <num_lo>0</num_lo> <num_med>0</num_med> <num_hi>0</num_hi> <ReportItem> <port>http (80/tcp)</port> <severity>0</severity> <pluginID>0</pluginID> <pluginName></pluginName> <data>PORT</data> </ReportItem> <ReportItem> <port>telnet (23/tcp)</port> <severity>0</severity> <pluginID>0</pluginID> <pluginName></pluginName> <data>PORT</data> </ReportItem> <ReportItem> <port>http (80/tcp)</port> <severity>0</severity> <pluginID>0</pluginID> <pluginName></pluginName> <data>PORT</data> </ReportItem> <ReportItem> <port>telnet (23/tcp)</port> <severity>0</severity> <pluginID>0</pluginID> <pluginName></pluginName> <data>PORT</data> </ReportItem> </ReportHost> <some-xml3> </some-xml3> </some-xml1> There are <reporthost> tags for one host and within that tag are <reportitem> tags for every item on that host. Now I need a way to extract hostnames from every <reporthost> and associate all the <pluginname> with that particular host. Any help will be appreciated. Thanks in advance i have a garbled list of email details in html how can i parse all the emails between: To: xxx@ccc.com Subject: thanks Ok there is more than one <land> on that xml. I need to parse out the name and cost and id of each land ... how can I do this? here is some of the xml Notice that there is more than one <land> entry, I need to parse out each land and have it assigned to a certain variable . thanks Code: [Select] <outer> − <xml> − <undeveloped_lands> − <land> <id>200</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fpawn%5Fshop%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Pawn%20Shop%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24200%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <cost>1000000000</cost> <is_racket>true</is_racket> <favor_points>0</favor_points> <purchase_limit>5</purchase_limit> <name>Pawn%20Shop</name> <income>$200,000</income> − <enhancements> − <enhancement> <value>1</value> − <suffix> % chance of a spirited defense (1/2x damage) when attacked </suffix> <prefix>+</prefix> <type>ATTACK_CRITICAL_DEFENSE_PERCENT</type> </enhancement> </enhancements> </land> − <land> <id>0</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fempty%5Flot%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Vacant%20Lot%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24100%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>4500</cost> <favor_points>0</favor_points> <name>Vacant%20Lot</name> <income>$100</income> </land> − <land> <id>1</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fempty%5Fstorefront%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Empty%20Storefront%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24300%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>45000</cost> <favor_points>0</favor_points> <name>Empty%20Storefront</name> <income>$300</income> </land> − <land> <id>201</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fscrap%5Fyard%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Scrap%20Yard%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24200%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <cost>1000000000</cost> <is_racket>true</is_racket> <favor_points>0</favor_points> <purchase_limit>5</purchase_limit> <name>Scrap%20Yard</name> <income>$200,000</income> − <enhancements> − <enhancement> <value>1</value> <suffix>% chance of critical hits in fights</suffix> <prefix>+</prefix> <type>ATTACK_CRITICAL_HIT_PERCENT</type> </enhancement> </enhancements> </land> − <land> <id>2</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fplaza%5Fv2%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Plaza%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%242%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>900000</cost> <favor_points>0</favor_points> <name>Plaza</name> <income>$2,000</income> </land> − <land> <id>9</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fbeach%5Flot%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Seaside%20Lot%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%248%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>3500000</cost> <favor_points>0</favor_points> <name>Seaside%20Lot</name> <income>$8,000</income> </land> − <land> <id>14</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fempty%5Ffield%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Empty%20Field%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24100%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>75000000</cost> <favor_points>0</favor_points> <name>Empty%20Field</name> <income>$100,000</income> </land> − <land> <id>23</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Foverseas%5Flot%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Overseas%20Lot%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2450%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>50000000</cost> <favor_points>0</favor_points> <name>Overseas%20Lot</name> <income>$50,000</income> </land> </undeveloped_lands> − <establishments> − <land> <id>24</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fundersea%5Fsmuggling%5Fstation%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Undersea%20Smuggling%20Station%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24100%2C000%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Seaside%20Lot%3C%2Fspan%3E </details> <num_owned>40</num_owned> <cost>200000000000</cost> <is_racket>false</is_racket> <favor_points>0</favor_points> <name>Undersea%20Smuggling%20Station</name> <income>$100,000,000</income> <built_on>Seaside%20Lot</built_on> <enhancements/> </land> − <land> <id>17</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fnewsstand%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Newsstand%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24100%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>5410</num_owned> <is_racket/> <cost>813000</cost> <favor_points>0</favor_points> <name>Newsstand</name> <income>$100</income> </land> − <land> <id>3</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Ftownhomes%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Townhomes%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24300%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Vacant%20Lot%3C%2Fspan%3E </details> <num_owned>2610</num_owned> <is_racket/> <cost>2358000</cost> <favor_points>0</favor_points> <name>Townhomes</name> <income>$300</income> <built_on>Vacant%20Lot</built_on> </land> − <land> <id>4</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fresturant%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Ristorante%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24700%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Vacant%20Lot%3C%2Fspan%3E </details> <num_owned>2180</num_owned> <is_racket/> <cost>5475000</cost> <favor_points>0</favor_points> <name>Ristorante</name> <income>$700</income> <built_on>Vacant%20Lot</built_on> </land> − <land> <id>5</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fcondos%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Condo%20Complex%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%245%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Empty%20Storefront%3C%2Fspan%3E </details> <num_owned>2430</num_owned> <is_racket/> <cost>39040000</cost> <favor_points>0</favor_points> <name>Condo%20Complex</name> <income>$5,000</income> <built_on>Empty%20Storefront</built_on> </land> − <land> <id>6</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fhotel%5Fv3%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Luxury%20Hotel%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2410%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Empty%20Storefront%3C%2Fspan%3E </details> <num_owned>2210</num_owned> <is_racket/> <cost>77700000</cost> <favor_points>0</favor_points> <name>Luxury%20Hotel</name> <income>$10,000</income> <built_on>Empty%20Storefront</built_on> </land> − <land> <id>18</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Foffice%5Fbuilding%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Office%20Building%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2420%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Vacant%20Lot%3C%2Fspan%3E </details> <num_owned>1290</num_owned> <is_racket/> <cost>156000000</cost> <favor_points>0</favor_points> <name>Office%20Building</name> <income>$20,000</income> <built_on>Vacant%20Lot</built_on> </land> − <land> <id>7</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fsky%5Fscraper%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Skyscraper%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24170%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Plaza%3C%2Fspan%3E </details> <num_owned>720</num_owned> <is_racket/> <cost>1314000000</cost> <favor_points>0</favor_points> <name>Skyscraper</name> <income>$170,000</income> <built_on>Plaza</built_on> </land> − <land> <id>8</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fcasino%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Resort%20Casino%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24350%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Plaza%3C%2Fspan%3E </details> <num_owned>590</num_owned> <is_racket/> <cost>2700000000</cost> <favor_points>0</favor_points> <name>Resort%20Casino</name> <income>$350,000</income> <built_on>Plaza</built_on> </land> − <land> <id>10</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fshipping%5Fyard%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Shipyard%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2420%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Seaside%20Lot%3C%2Fspan%3E </details> <num_owned>250</num_owned> <is_racket/> <cost>156000000</cost> <favor_points>0</favor_points> <name>Shipyard</name> <income>$20,000</income> <built_on>Seaside%20Lot</built_on> </land> − <land> <id>11</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fharbor%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Yacht%20Harbor%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2450%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Seaside%20Lot%3C%2Fspan%3E </details> <num_owned>780</num_owned> <is_racket/> <cost>395000000</cost> <favor_points>0</favor_points> <name>Yacht%20Harbor</name> <income>$50,000</income> <built_on>Seaside%20Lot</built_on> </land> − <land> <id>12</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fresort%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Seaside%20Resort%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24200%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Seaside%20Lot%3C%2Fspan%3E </details> <num_owned>760</num_owned> <is_racket/> <cost>1540000000</cost> <favor_points>0</favor_points> <name>Seaside%20Resort</name> <income>$200,000</income> <built_on>Seaside%20Lot</built_on> </land> − <land> <id>13</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fmall%5Fv3%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Downtown%20Shopping%20Mall%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24500%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Plaza%3C%2Fspan%3E </details> <num_owned>750</num_owned> <is_racket/> <cost>3800000000</cost> <favor_points>0</favor_points> <name>Downtown%20Shopping%20Mall</name> <income>$500,000</income> <built_on>Plaza</built_on> </land> − <land> <id>19</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fland%5Fmark%5Fcasino%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Landmark%20Casino%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24550%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Empty%20Field%3C%2Fspan%3E </details> <num_owned>400</num_owned> <is_racket/> <cost>4100000000</cost> <favor_points>0</favor_points> <name>Landmark%20Casino</name> <income>$550,000</income> <built_on>Empty%20Field</built_on> </land> − <land> <members_req>50</members_req> <id>15</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fhelipad%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Helipad%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%24600%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Vacant%20Lot%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%3EEach%20Requires%2050%20Mob%20Members </details> <num_owned>12</num_owned> <is_racket/> <cost>660000000</cost> <favor_points>0</favor_points> <name>Helipad</name> <income>$600,000</income> <built_on>Vacant%20Lot</built_on> </land> − <land> <members_req>60</members_req> <id>16</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fairport%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Airport%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%241%2C000%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Empty%20Field%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%3EEach%20Requires%2060%20Mob%20Members </details> <num_owned>10</num_owned> <is_racket/> <cost>1800000000</cost> <favor_points>0</favor_points> <name>Airport</name> <income>$1,000,000</income> <built_on>Empty%20Field</built_on> </land> − <land> <id>22</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fforeign%5Fembassy%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Foreign%20Embassy%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%242%2C000%2C000%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landBuiltOn%27%20style%3D%27color%3A%23FFFFFF%27%3EBuilt%20On%3A%20Overseas%20Lot%3C%2Fspan%3E </details> <num_owned>100</num_owned> <is_racket/> <cost>16500000000</cost> <favor_points>0</favor_points> <name>Foreign%20Embassy</name> <income>$2,000,000</income> <built_on>Overseas%20Lot</built_on> </land> </establishments> <featured_lands/> − <locked_lands> − <land> <id>20</id> − <image_url> http%3A%2F%2Fcdn0%2Emobwarsapp%2Ecom%2Frpg%5Fimages%2Fopensocial%2Fmob%2Fingame%2Fterritory%2Fbig%2Fcatskill%5Fresort%2Egif </image_url> − <details> %3Cspan%20class%3D%27landName%27%20style%3D%27color%3A%23FFFFFF%3B%20font%2Dsize%3A18px%3B%20font%2Dweight%3Abold%3B%27%3E%20Catskill%20Resort%3C%2Fspan%3E%3Cbr%3E%3Cspan%20class%3D%27landIncome%27%20style%3D%27color%3A%23FFFFFF%27%3EIncome%3A%20%2425%2C000%3C%2Fspan%3E%3Cbr%3E </details> <num_owned>0</num_owned> <is_racket/> <cost>0</cost> <no_sell>true</no_sell> <favor_points>0</favor_points> <name>Catskill%20Resort</name> <income>$25,000</income> − <enhancements> − <enhancement> <value>2</value> <suffix>max energy</suffix> <prefix>+</prefix> <type>MAX_ENERGY_INCREASE</type> </enhancement> </enhancements> </land> </locked_lands> <num_mob_used>1200</num_mob_used> <num_mob_available>238</num_mob_available> <update_period>55</update_period> <minutes_to_update>9</minutes_to_update> <get_city_list>true</get_city_list> <request_id>7215441</request_id> </xml> </outer> I've been reading parsing xml with php forums all day and still can't seem to figure out how to start with this one. there is a node he http://xml.heroesofnewerth.com/xml_requester.php?f=match_stats&opt=mid&mid[]=30428528 called match_stats. All i need help with is how to get those 10 elements inside match_stats and how to grab the stat name= nickname from each element. I'm just looking for somewhere to start and I'm sure I can figure out the rest. Thanks Hello to all Can someone help me on how can i parse this XML string? Code: [Select] <?php <?xml version="1.0" encoding="UTF-8"?><SendSMSResponse><Transaction><IP>120.28.199.73</IP><Code>1</Code><Description>Transaction OK</Description></Transaction><Destinations><Destination><Number> +639217195804 </Number><Code>1</Code></Destination></Destinations></SendSMSResponse> ?> I would like to get the word "Transaction OK" but i dont know where to start. thanks in advance I need to parse XML and this article helped me a lot: http://www.phpfreaks.com/tutorial/handling-xml-data The next thing I need is to parse only elements that meet certain conditions, lets say we have an XML with structure like this: <Result> <Line> <StockCode>0101009</StockCode> <Description>Description</Description> <ProductGroup>S01</ProductGroup> <Availability>0</Availability> </Line> ... </Result> I need to parse only the elements with ProductGroup = S01 and Availability = 1 How can I do that Hi All, I'm attempting to parse some XML and am having some trouble It seems that I'm grabbing the elements correctly, but they don't seem to be assigning themselves. When I try to echo the value, there's nothing. It's probably some novice error (i'm new to PHP), so any help would be greatly appreciated! Code: [Select] $fp = fopen("MY URL HERE", "r"); if ($fp) { echo "Made the check!\n"; while (!feof($fp)) $gamerfeed .= fgets($fp); if ($gamerfeed != '') { $dom = new DomDocument(); $dom->recover=true; @$dom->loadXML($gamerfeed); $RecentGames = $dom->getElementsByTagName('ArrayOfGame')->item(0); $HasEvents = false; // Loop through each Game within RecentGames foreach($RecentGames->getElementsByTagName('Game') as $GameNode) { $HasEvents = true; // Get the Game Attributes from within RecentGames $Name = $GameNode->getElementsByTagName('Title')->textContent; echo($Name); It doesn't echo the name! Here's the XML I'm grabbing: Code: [Select] <?xml version="1.0"?> <ArrayOfGame> <Game> <Id>NPWR00449_00</Id> <IdGameEurope>75</IdGameEurope> <Title>Uncharted: Drakes Fortune</Title> </Game> </ArrayOfGame> I'm still learning parsing, so sorry if it's obvious thanks! john Alright, I'm trying to get the numbers in divs with with the class of content I have been using this but its not working <?php error_reporting(E_ALL); ini_set('display_errors', 1); include(dirname(__FILE__) .'/include/simple_html_dom.php'); //playlist page $playlist_page = 'http://www.bungie.net/stats/reach/online.aspx'; //create dom $html = new simple_html_dom(); $html->load_file($playlist_page); //get all divs $get_divs = ''; $get_divs_el = $html->find('li.glowBox'); if (preg_match_all('|<div[^>]+>(.*)</div>|U', $get_divs_el[0]->innertext, $matches)) { $get_divs = $matches[0]; } print_r($get_divs_el); print_r($get_divs); ?> Code: [Select] <ul> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl00_nameLink" href="/stats/reach/playlists.aspx?p=29898">NOBLE MAP PACK</a> </h4> 1,192 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl01_nameLink" href="/stats/reach/playlists.aspx?p=30228">COMMUNITY SLAYER</a> </h4> Available 2.08.2011 </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl02_nameLink" href="/stats/reach/playlists.aspx?p=30353">GRIFBALL</a> </h4> Available 2.08.2011 </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl03_nameLink" href="/stats/reach/playlists.aspx?p=30446">FIREFIGHT LIMITED</a> </h4> Available 2.08.2011 </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl04_nameLink" href="/stats/reach/playlists.aspx?p=30291">FIREFIGHT ARCADE</a> </h4> Available 2.08.2011 </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl05_nameLink" href="/stats/reach/playlists.aspx?p=25886">RUMBLE PIT</a> </h4> 4,586 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl06_nameLink" href="/stats/reach/playlists.aspx?p=29220">LIVING DEAD</a> </h4> 4,684 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl07_nameLink" href="/stats/reach/playlists.aspx?p=25885">TEAM SLAYER</a> </h4> 14,501 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl08_nameLink" href="/stats/reach/playlists.aspx?p=29978">MLG</a> </h4> 1,457 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl09_nameLink" href="/stats/reach/playlists.aspx?p=28808">TEAM SWAT</a> </h4> 9,670 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl10_nameLink" href="/stats/reach/playlists.aspx?p=29219">TEAM SNIPERS</a> </h4> 3,051 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl11_nameLink" href="/stats/reach/playlists.aspx?p=28474">TEAM OBJECTIVE</a> </h4> 1,208 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl12_nameLink" href="/stats/reach/playlists.aspx?p=28475">MULTI TEAM</a> </h4> 2,306 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl13_nameLink" href="/stats/reach/playlists.aspx?p=28476">BIG TEAM BATTLE</a> </h4> 6,621 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl14_nameLink" href="/stats/reach/playlists.aspx?p=28477">INVASION</a> </h4> 2,475 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl15_nameLink" href="/stats/reach/playlists.aspx?p=28478">FIREFIGHT</a> </h4> 6,302 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl16_nameLink" href="/stats/reach/playlists.aspx?p=28479">SCORE ATTACK</a> </h4> 1,568 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl17_nameLink" href="/stats/reach/playlists.aspx?p=28779">CO-OP CAMPAIGN</a> </h4> 285 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl18_nameLink" href="/stats/reach/playlists.aspx?p=28481">TEAM ARENA</a> </h4> 1,228 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl19_nameLink" href="/stats/reach/playlists.aspx?p=28480">DOUBLES ARENA</a> </h4> 1,571 Players </div> </li> <li class="glowBox"> <div class="corner bottomLeft"></div> <div class="corner topRight"></div> <div class="content"> <h4><a id="ctl00_mainContent_playlistRepeater_ctl20_nameLink" href="/stats/reach/playlists.aspx?p=30227">FFA ARENA</a> </h4> 235 Players </div> </li> </ul> what is wrong with this code? I want to parse rss content and its giving error that, the input is not corret $xmlDoc = new DOMDocument(); $xml="http://www.pharmamanufacturing.com/index.html?mode=rss"; $xmlDoc->loadxml($xml); //$xmlDoc->load($xml); Hello requinix. I am taking advantage of this thread to expose my problem: It looks like the load function does NOT work properly and I CANNOT find the reason why: Code: [Select] $xml = new DOMDocument(); $xml->load("data/slides.xml"); In debugging, I can see the creation of a DOMDocument but the load function does not fill the $xml with the relative data even if it returns True: Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <album> <slide url="data/327.jpg" rel_URL="show_craft.php?id=327" title="Art. 327"></slide> <slide url="data/330.jpg" rel_URL="show_craft.php?id=330" title="Art. 330"></slide> <slide url="data/311.jpg" rel_URL="show_craft.php?id=311" title="Art. 311"></slide> <slide url="data/239.jpg" rel_URL="show_craft.php?id=239" title="Art. 239"></slide> <slide url="data/275.jpg" rel_URL="show_craft.php?id=275" title="Art. 275"></slide> <slide url="data/IMG_2691.jpg" rel_URL=" " title="Art. IMG_2691"></slide> <slide url="data/IMG_2684.jpg" rel_URL=" " title="Art. IMG_2684"></slide> <slide url="data/crafts 023.jpg" rel_URL=" " title="Art. crafts 023"></slide> </album> I use XAMPP 1.7.7. In php.net, under DOMDocument::load page, there is a post that says "Function will not work if using XML DOM PECL module". In my phpinfo() there is only the "PECL Module version 2.0-dev $Id: sqlite.c 306939 2011-01-01 02:19:59Z felipe $ " under SQLite section enabled. I tried many things like changing xml path, replacing the xml file with a simpler one from, for example, w3schools but with no avail. I still get an empty document. I don't know where to bang my head since it looks like it's only me having this issue (search the web extensively). Any help is greatly appreciated. Thank you Hi I have an XML file that I've been trying to parse with some success. Code: [Select] <?xml version='1.0' encoding='ISO-8859-1'?> <Notes> <Madrid> <trip> <ID>12518980</ID> <Duration>130</Duration> </trip> <trip> <ID>12518981</ID> <Duration>600</Duration> </trip> <trip> <ID>12518982</ID> <Duration>50</Duration> </trip> </Madrid> <London> <trip> <ID>12518983</ID> <Duration>Suzuki</Duration> </trip> </London> <Chicago> <trip> <ID>12518984</ID> <Duration>1600</Duration> </trip> <Chicago> </Notes> I am able to get all the nodes that I want, which is mainly ID and duration using: Code: [Select] $objDOM = new DOMDocument(); $objDOM->load("data.xml"); $note = $objDOM->getElementsByTagName("trip"); foreach( $note as $value ) { $ids = $value->getElementsByTagName("ID"); $id = $ids->item(0)->nodeValue; $durations = $value->getElementsByTagName("Duration"); $duration = $duration->item(0)->nodeValue; echo "ID is:".$id."<br />"; echo "Duration is:".$duration."<br />"; } What I'd really like to do, is to the get duration and ID for each of the parent nodes, i.e. Mardid, London and Chicago, without having 3 separate foreach loops, if that is possible? Hi, I want this function to output all the nodes of the email.xml file. But for some reason, it only outputs "ELEMENT NODE: email" Please see the first post in this SimpleXML thread and the PHP help topic is SimpleXML whereas this one is just pure DOM BUT both are using email.xml (please see link below) or if it is broken, please search for PHP help topic: Need help with SimpleXML to check if node has attributes http://www.phpfreaks.com/forums/index.php?topic=346028.0 Here is the script: Code: [Select] <?php /*FOR DOM */ $dom=new DOMDocument(); $dom->load("email.xml"); function writeXMLtoScreenViaDOM($dom) { //print current tag node names // if current tag node has whitespace, go to the next sibling that's // guaranteed to be a tag node if(trim($dom->firstChild->nodeName)=="") { $dom=$dom->nextSibling; } print "<strong>ELEMENT NODE:</strong>".$dom->nodeName."<br />"; //print the current tag node's text node child if any if($dom->nodeType==XML_TEXT_NODE) { if(trim($dom->nodeValue)=="") print "<strong>TEXT NODE:</strong> has child tag nodes.<br />"; else print "<strong>TEXT NODE:</strong>".$dom->nodeValue."<br />"; } //print any attributes // NB: later make sure to skip over EMPTY ATTRIBUTE NODE VALUES if($dom->hasAttributes()) { for($i=0;$i<$dom->length;$i++) { print "<strong>ATTRIBUTE NODE:</strong>".$dom->attributes->item($i)->nodeValue."<br />"; } } //check if any child tag nodes if($dom->hasChildNodes()) { //NB: think need for loop to know what the current index in item(index) is foreach($dom->childNodes->item(0) AS $curNode) writeXMLtoScreenViaDOM($curNode); } }//END FCN writeXMLtoScreenViaDOM writeXMLtoScreenViaDOM($dom->documentElement); ?> Please any help is appreciated! Hello everyone! I have been trying to figure out how I can go about this, and failing. I have a text file that lists records simply: ex: 99. I got in my friends "car", what a piece of crap... ex:100. It only goes 25mph. I need to parse it so that it uses the number to store in the table, or just remove everything and store the text to the end, using an auto increment for the line number(some span more than one line). The numbers cannot be used as a key either. The number of spaces after the number and period also varies, from 1-4. The text also contains other special characters such as quotes, numbers, commas, periods. Anyone have any ideas? |