PHP - Xml Parsing In Php/query
Hello I'm having some trouble with a certain PHP file. I have a database created on my local server and need to use PHP to generate XML from the tables in the database.
The code works when I try to retrieve data from only one table but I can't seem to figure out how to query multiple tables. This is a snippet of the code: Code: [Select] $connection = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $connection) or die("Could not find database."); $query = "SELECT * FROM department"; $resultSet = mysql_query($query, $connection) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<school>\n"; for($x = 0 ; $x < mysql_num_rows($resultSet) ; $x++){ $row = mysql_fetch_assoc($resultSet); $xml_output .= "\t<department>\n"; $xml_output .= "\t\t<name>" . $row['name'] . "</name>\n"; $xml_output .= "\t\t<code>" . $row['code'] . "</code>\n"; $xml_output .= "\t</department>\n"; $xml_output .= "\t<program>\n"; $xml_output .= "\t\t<name>" . $row['name'] . "</name>\n"; $xml_output .= "\t\t<department>" . $row['department'] . "</department>\n"; $xml_output .= "\t\t<co-op>" . $row['co-op'] . "</co-op>\n"; $xml_output .= "\t</program>\n"; The department table contains values of name and code. The program table contains values of name, department and co-op. My question is how would I go about printing all of the contents of the department and program tables? Similar TutorialsHello, I am doing a hotel reservation website.First am getting the checkin (arrival) and Check out(Departure) date from user.Then in next from i fetch both this values using POST method and store it in variable $arrival and $departure and then am formattind the date as i want it in the form YYYY-MM-DD(My SQL). Then am using the value of variable $arr and $dep in a query to fetch the records from DB but it is giving error.But when i do it in Hard code way I mean directly inserting the date in query it is running smmothly.Please help!!!! Am using Xampp 2.5 Heres my code... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>ROOMS</title> <?php $arrival = $_POST['start']; $departure = $_POST['end']; $adults=6; $child=2; $room_id=101; function changeFormatDate($cdate){ list($day,$month,$year)=explode("/",$cdate); return $year."-".$month."-".$day; } // $arr="'".$arr."'"; $arr= changeFormatDate($arrival); //settype($arr, "string"); // $timestamp=strtotime($arr1); // $arr=date("Y-m-d",$timestamp); $dep= changeFormatDate($departure); // $timestamp=strtotime($dep1); // $dep=date("Y-m-d",$timestamp); ?> <style type="text/css"> <!-- .style2 { font-size: 12px; font-weight: bold; } --> </style> </head> <body> <!-- TOP --> <div id="top1"><a href="index.php"></a></div> <div id="top"> <ul class="menu"> <li class="home"><a href="index.php">Home</a></li> <li class="about"><a href="about.php">About</a></li> <li class="contacts"><a href="contact.php">Contacts</a></li> <li class="renting"><a href="gallery.php">GALLERY</a></li> <li class="selling"><a href="rates.php">RATES</a></li> </ul> </div> <!-- HEADER --> <!-- CONTENT --> <div id="content"> <div id="leftPan"> <div id="services"> <h2>RESERVATION DETAILS </h2> <p> <ul> Check In Date :<?php echo $arrival; ?><br /> Check Out Date :<?php echo $departure; ?> <br /> </ul> </p> </p> </div> </div> <div id="featured"><br /> <div> <form action="personnalinfo.php" method="post" onsubmit="return validateForm()" name="room"> <input name="start" type="hidden" value="<?php echo $arrival; ?>" /> <input name="end" type="hidden" value="<?php echo $departure; ?>" /> <input name="rooms" id="rooms" type="hidden" /> <input name="adult" type="hidden" value="<?php echo $adults; ?>" /> <input name="child" type="hidden" value="<?php echo $child; ?>" /> </div> <table bgcolor="white" border="1" width="100%" style="float:left;table-layout:fixed" cellpadding="10" cellspacing="0" > <col width="70%"> <tr> <th colspan="2" bgcolor="white"><h2><font color=maroon>Room Type</font></h2></th> </tr> <tr> <td> <table border="0" style="float:left;table-layout:fixed" width="100%"> <col width="55%"> <tr> <td valign="top"> <img src="img1/apt.jpg" style="float:left" /> </br> <div style="margin-top:120px;margin-left:5px"> <img src="img1/apt1.jpg" /> <img src="img1/apt2.jpg" /> <img src="img1/apt3.jpg" /> </div> </td> <td> <h3>Appartment</h3> <br> <span class="price">Price:</span> <span class="number">Rs. 5,000.00</span><br /> <a> Apparment in HOTEL BELLA has 2 Rooms with connecting door.It can accomodate 4 Adult and 2 children. And are located on Beach side to give you comfort and a panoramic view so that you can have a luxury accommodation.<br> *Sitting area <br>*jacuzzi shower</br> *Large terrace overlooking the sea *Jacuzzi *Light therapy *Air treatment <a href="#">more...</a></p><br /> </td> </tr> </table> </td> <td valign="top"> <table border=0 width="100%" cellspacing="10"> <tr> <td align="left"> <label><h3>People : </h3></label> </td> <td align="right"> <img src="img1/i1.jpg" /> </td> </tr> <tr> <td align="left" > <label><h3>Rooms : </h3></label> </td> <td align="right" > <?php gen_options("single")?> </td> </tr> </table> </td> </tr> <tr> <td> <table border="0" style="float:left;table-layout:fixed" width="100%"> <col width="55%"> <tr> <td valign="top"> <img src="img1/double.jpg" style="float:left" /> </br> <div id="featured"> <img src="img1/double1.jpg" /> <img src="img1/double2.jpg" /> <img src="img1/double3.jpg" /> </div> </td> <td> <h3>Double</h3> <br> <span class="price">Price:</span> <span class="number">Rs. 3,000.00</span><br /> <a>Double rooms in HOTEL BELLA has Double bed. And can accomodate 2 Adults and 2 kids. It is comfortable and pleasant, with balcony and sea view. We hope that you will enjoy your summer holidays in Bella. BASIC: Telephone. Satellite TV. Safety Deposit Box. Mini Bar - Refrigerator. Air condition. Shower with or without cabin. Hair Dryer. Balcony.<a href="#">more...</a></p><br /> </td> </tr> </table> </td> <td valign="top"> <table border=0 width="100%" cellspacing="10"> <tr> <td align="left"> <label><h3>People : </h3></label> </td> <td align="right"> <img src="img1/i2.jpg" /> </td> </tr> <tr> <td align="left"> <label><h3>Rooms : </h3></label> </td> <td align="right" > <?php gen_options("double")?> </td> </tr> </table> </td> </tr> <tr> <td> <table border="0" style="float:left;table-layout:fixed" width="100%"> <col width="55%"> <tr> <td valign="top"> <img src="img1/single.jpg" style="float:left" /> </br> <div id="featured"> <img src="img1/single1.jpg" /> <img src="img1/single2.jpg" /> <img src="img1/single3.jpg" /> </div> </td> <td> <h3>Single</h3> <br> <span class="price">Price:</span> <span class="number">Rs. 2,000.00</span><br /> <a> Single Room in HOTEL BELLA has single bed, bathroom.Can accomodated single person. is comfortable and pleasant, with balcony and sea view Telephone Satellite TV Safety Deposit Box Mini Bar - Refrigerator Air condition Hair Dryer <a href="#">more...</a></p><br /> </td> </tr> </table> </td> <td valign="top"> <table border=0 width="100%" cellspacing="10"> <tr> <td align="left"> <label><h3>People : </h3></label> </td> <td align="right"> <img src="img1/i3.jpg" /> </td> </tr> <tr> <td align="left"> <label><h3>Rooms : </h3></label> </td> <td align="right" > <?php gen_options("apartment")?> </td> </tr> </table> </td> </tr> </table> <div style="margin-top:1200px;margin-left:5px;text-align:right;"> <input type="image" src="img1/book.jpg" name="book" value="submit"/> </div> <?php function gen_options($type) { // print "$id"; // print "$type"; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("hotel", $con); $count=0; $result = mysql_query("SELECT * FROM rooms where type='$type'"); while($row = mysql_fetch_array($result)) { $a=$row['room_no']; //print "$a"; // $query1 = mysql_query("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and status='active'"); // $query=mysql_query("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and ((arrival<='2012-05-11' AND departure>='2012-05-11')OR(arrival<='2012-05-13' AND departure>='2012-05-13'))"); //$query=mysql_query("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and ((arrival BETWEEN '2012-05-11' AND '2012-05-13') or (departure BETWEEN '2012-05-11' AND '2012-05-13'))"); //$query=mysql_query("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and ((arrival<='$arr' AND departure>='$arr')OR(arrival<='$dep' AND departure>='$dep'))"); $quer=sprintf("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and ((arrival<='%s' AND departure>='%s')OR(arrival<='%s' AND departure>='%s'))",$arr,$arr,$dep,$dep); $query=mysql_query($quer); //$query=mysql_query("SELECT count(*) FROM `room_inventory` WHERE room_no='$a' and ((arrival BETWEEN '$arr' AND '2012-05-13') or (departure BETWEEN '$arr' AND '2012-05-13'))"); $r=mysql_fetch_array($query); $v=$r['count(*)']; // print "$v"; if($v==0) { $count++; // print "$count"; } } echo '<select name="room1" class="ed" id="r1">'; for($i=0;$i<=$count;$i++) { echo '<option>'.$i.'</option>'; } echo '</select>'; mysql_close($con); } // echo "$arrival\n"; // print "$departure\n"; echo "$arr"; echo "$dep"; // echo date_format($arrival, 'Y-m-d'); ?> <input type="hidden" name="result" id="result" /> </form> </div> <div class="clear"></div> </div> <!-- FOOTER --> <div id="footer"> <p><a href="index.php">HOME</a> |<a href="about.php"> ABOUT US </a>|<a href="contact.php"> CONTACTS </a>|<a href="gallery.php"> GALLERY </a>|<a href="rates.php"> ROOM RATES </a></p> </div> </body> </html> Hello all,
Based on the suggestion of you wonderful folks here, I went away for a few days (to learn about PDO and Prepared Statements) in order to replace the MySQLi commands in my code. That's gone pretty well thus far...with me having learnt and successfully replaced most of my "bad" code with elegant, SQL-Injection-proof code (or so I hope).
The one-and-only problem I'm having (for now at least) is that I'm having trouble understanding how to execute an UPDATE query within the resultset of a SELECT query (using PDO and prepared statements, of course).
Let me explain (my scenario), and since a picture speaks a thousand words I've also inlcuded a screenshot to show you guys my setup:
In my table I have two columns (which are essentially flags i.e. Y/N), one for "items alreay purchased" and the other for "items to be purchased later". The first flag, if/when set ON (Y) will highlight row(s) in red...and the second flag will highlight row(s) in blue (when set ON).
I initially had four buttons, two each for setting the flags/columns to "Y", and another two to reverse the columns/flags to "N". That was when I had my delete functionality as a separate operation on a separate tab/list item, and that was fine.
Now that I've realized I can include both operations (update and delete) on just the one tab, I've also figured it would be better to pare down those four buttons (into just two), and set them up as a toggle feature i.e. if the value is currently "Y" then the button will set it to "N", and vice versa.
So, looking at my attached picture, if a person selects (using the checkboxes) the first four rows and clicks the first button (labeled "Toggle selected items as Purchased/Not Purchased") then the following must happen:
1. The purchased_flag for rows # 2 and 4 must be switched OFF (set to N)...so they will no longer be highlighted in red.
2. The purchased_flag for row # 3 must be switched ON (set to Y)...so that row will now be highlighted in red.
3. Nothing must be done to rows # 1 and 5 since: a) row 5 was not selected/checked to begin with, and b) row # 1 has its purchase_later_flag set ON (to Y), so it must be skipped over.
Looking at my code below, I'm guessing (and here's where I need the help) that there's something wrong in the code within the section that says "/*** loop through the results/collection of checked items ***/". I've probably made it more complex than it should be, and that's due to the fact that I have no idea what I'm doing (or rather, how I should be doing it), and this has driven me insane for the last 2 days...which prompted me to "throw in the towel" and seek the help of you very helpful and intellegent folks. BTW, I am a newbie at this, so if I could be provided the exact code, that would be most wonderful, and much highly appreciated.
Thanks to you folks, I'm feeling real good (with a great sense of achievement) after having come here and got the great advice to learn PDO and prepared statements.
Just this one nasty little hurdle is stopping me from getting to "end-of-job" on my very first WebApp. BTW, sorry about the long post...this is the best/only way I could clearly explaing my situation.
Cheers guys!
case "update-delete": if(isset($_POST['highlight-purchased'])) { // ****** Setup customized query to obtain only items that are checked ****** $sql = "SELECT * FROM shoplist WHERE"; for($i=0; $i < count($_POST['checkboxes']); $i++) { $sql=$sql . " idnumber=" . $_POST['checkboxes'][$i] . " or"; } $sql= rtrim($sql, "or"); $statement = $conn->prepare($sql); $statement->execute(); // *** fetch results for all checked items (1st query) *** // $result = $statement->fetchAll(); $statement->closeCursor(); // Setup query that will change the purchased flag to "N", if it's currently set to "Y" $sqlSetToN = "UPDATE shoplist SET purchased = 'N' WHERE purchased = 'Y'"; // Setup query that will change the purchased flag to "Y", if it's currently set to "N", "", or NULL $sqlSetToY = "UPDATE shoplist SET purchased = 'Y' WHERE purchased = 'N' OR purchased = '' OR purchased IS NULL"; $statementSetToN = $conn->prepare($sqlSetToN); $statementSetToY = $conn->prepare($sqlSetToY); /*** loop through the results/collection of checked items ***/ foreach($result as $row) { if ($row["purchased"] != "Y") { // *** fetch one row at a time pertaining to the 2nd query *** // $resultSetToY = $statementSetToY->fetch(); foreach($resultSetToY as $row) { $statementSetToY->execute(); } } else { // *** fetch one row at a time pertaining to the 2nd query *** // $resultSetToN = $statementSetToN->fetch(); foreach($resultSetToN as $row) { $statementSetToN->execute(); } } } break; }CRUD Queston.png 20.68KB 0 downloads Here is my code: // Start MySQL Query for Records $query = "SELECT codes_update_no_join_1b" . "SET orig_code_1 = new_code_1, orig_code_2 = new_code_2" . "WHERE concat(orig_code_1, orig_code_2) = concat(old_code_1, old_code_2)"; $results = mysql_query($query) or die(mysql_error()); // End MySQL Query for Records This query runs perfectly fine when run direct as SQL in phpMyAdmin, but throws this error when running in my script??? Why is this??? Code: [Select] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= new_code_1, orig_code_2 = new_code_2WHERE concat(orig_code_1, orig_c' at line 1 If you also have any feedback on my code, please do tell me. I wish to improve my coding base. Basically when you fill out the register form, it will check for data, then execute the insert query. But for some reason, the query will NOT insert into the database. In the following code below, I left out the field ID. Doesn't work with it anyways, and I'm not sure it makes a difference. Code: Code: [Select] mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); Full code: Code: [Select] <?php include_once("includes/config.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><? $title; ?></title> <meta http-equiv="Content-Language" content="English" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <div id="wrap"> <div id="header"> <h1><? $title; ?></h1> <h2><? $description; ?></h2> </div> <? include_once("includes/navigation.php"); ?> <div id="content"> <div id="right"> <h2>Create</h2> <div id="artlicles"> <?php if(!$_SESSION['user']) { $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $name = mysql_real_escape_string($_POST['name']); $server_type = mysql_real_escape_string($_POST['type']); $description = mysql_real_escape_string($_POST['description']); if(!$username || !$password || !$server_type || !$description || !$name) { echo "Note: Descriptions allow HTML. Any abuse of this will result in an IP and account ban. No warnings!<br/>All forms are required to be filled out.<br><form action='create.php' method='POST'><table><tr><td>Username</td><td><input type='text' name='username'></td></tr><tr><td>Password</td><td><input type='password' name='password'></td></tr>"; echo "<tr><td>Sever Name</td><td><input type='text' name='name' maxlength='35'></td></tr><tr><td>Type of Server</td><td><select name='type'> <option value='Any'>Any</option> <option value='PvP'>PvP</option> <option value='Creative'>Creative</option> <option value='Survival'>Survival</option> <option value='Roleplay'>RolePlay</option> </select></td></tr> <tr><td>Description</td><td><textarea maxlength='1500' rows='18' cols='40' name='description'></textarea></td></tr>"; echo "<tr><td>Submit</td><td><input type='submit'></td></tr></table></form>"; } elseif(strlen($password) < 8) { echo "Password needs to be higher than 8 characters!"; } elseif(strlen($username) > 13) { echo "Username can't be greater than 13 characters!"; } else { $check1 = mysql_query("SELECT username,name FROM servers WHERE username = '$username' OR name = '$name' LIMIT 1"); if(mysql_num_rows($check1) < 0) { echo "Sorry, there is already an account with this username and/or server name!"; } else { $ip = $_SERVER['REMOTE_ADDR']; mysql_query("INSERT INTO servers (username, password, name, type, description, ip, votes, beta) VALUES ($username, $password, $name, $server_type, $description, $ip, 0, 1)"); echo "Server has been succesfully created!"; } } } else { echo "You are currently logged in!"; } ?> </div> </div> <div style="clear: both;"> </div> </div> <div id="footer"> <a href="http://www.templatesold.com/" target="_blank">Website Templates</a> by <a href="http://www.free-css-templates.com/" target="_blank">Free CSS Templates</a> - Site Copyright MCTop </div> </div> </body> </html> 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? 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> How can I access the id part? <EXM id="1233456"><products>...</products></EXM> Basically I'm reading a local xml file, extracting data, and passing array over to a MySql function. Also, when each record is extracted I need to know the full parent-child category it was listed under. for example: <root> <node value="first"/> <node value="second"/> <header label="Numbers"> <header label="Roman numerals"> <node value="I"/> <node value="XV"/> </header> <node value="1"/> <node value="10"/> </header> </root> 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> Hello, I have an xml file below with multiple namespaces called "date". I want to know how to echo out each date that is associated with that "item" if that makes sense. Thanks Code: [Select] <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel> <item> <title>My Title</title> <dc:date>2009-02-12</dc:date> <dc:date>2010-09-01</dc:date> </item> </channel> </rss> 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 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? I can't seem to get this to parse into an array:
<?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <ns:getReportTestResponse xmlns:ns="http://webservice.avm.pvads.com"> <ns:return xmlns:ax21="http://webservice.avm.pvads.com/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:WSReportBean"> <ax21:confidence /> <ax21:dateStamp>12/07/2007</ax21:dateStamp> <ax21:html>adsasdasdsadasd</ax21:html> <ax21:pdsReference /> <ax21:product>AVi (Exterior AND Interior Inspection) - 48hr RUSH</ax21:product> <ax21:sourceData /> <ax21:successful>true</ax21:successful> <ax21:value>168000.0</ax21:value> </ns:return> </ns:getReportTestResponse> </soapenv:Body> </soapenv:EnvelopeTried simplexml_load_string and comes back with nothing. Any help would be great thanks. 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 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 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); 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. 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 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 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! |