Jump to content

PHP and XML "database" trouble.


i73

Recommended Posts

Hey guys I am trying to read my xml file and itterate through the list. I am having trouble. 

<?xml version="1.0" encoding="UTF-8"?>
<stock>

	<itemPlace id="1">
		<name>null</name>
		<image>null</image>
		<wholeSale>44</wholeSale>
		<retailPrice>null</retailPrice>
		<quantity>null</quantity>
		<location>null</location>
		<color>null</color>
		<size>null</size>
		<weight>null</weight>
		<description>null</description>
		<itemType>null</itemType>
		<date>null</date>
	</itemPlace>
	<itemPlace id="2">
		<name>null</name>
		<image>null</image>
		<wholeSale>55</wholeSale>
		<retailPrice>null</retailPrice>
		<quantity>null</quantity>
		<location>null</location>
		<color>null</color>
		<size>null</size>
		<weight>null</weight>
		<description>null</description>
		<itemType>null</itemType>
		<date>null</date>
	</itemPlace>
</stock>
<?php 
		$xml = simplexml_load_file('stock.xml');
		foreach ($xml->xpath('itemPlace') as $eq) 
		{
			echo "<p><a class='inline' href=\"#inline_content\"> {$eq->name}</a></p>";
		    echo '<br>';
		    
		  	echo " <div style='display:none'>";
		   	echo " <div id='inline_content' style='padding:10px; background:#fff;'>";
		   	echo " <p>";
		    	
			echo "  <strong>{$eq->wholeSale}</strong>";
                        echo "</div></div>";

Is there a way I can look up the object through the itemPlace id="#" and call out the parameters of the item? Like the name price, etc?

 

I know how to mySQL query but not XML, and this is a project that needs to use xml... FML..I have been looking for a few hours so any help would be appreciated! :) 

Link to comment
https://forums.phpfreaks.com/topic/288449-php-and-xml-database-trouble/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.