PHP - Xml Parsing Help
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> Similar TutorialsHello 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 How can I access the id part? <EXM id="1233456"><products>...</products></EXM> 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? 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 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 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> 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 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. 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); 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 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> 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! 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. 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 have a garbled list of email details in html how can i parse all the emails between: To: xxx@ccc.com Subject: 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 Hi there everyone... Hi,
I have a string that looks like this:
{
"cmd": "VarReturn",
"name": "temperature",
"result": 947,
"coreInfo": {
"last_app": "",
"last_heard": "2014-07-14T11:46:17.865Z",
"connected": true,
"deviceID": "234y8172390dfsa"
}
}
which I have fetched from a web page using file_get_contents();
How do I put the data into variables? Either a variable for each piece of data eg $cmd = "VarReturn", $name="temperature" or into an array?
At the moment I'm doing it the very messy way of using strpos() to look for each section, but I'm fairly sure there's a much easier way (using regular expressions?) but I'm a bit stuck on where to start.
Any help would be much appreciated.
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? |