View Single Post
Old 02-10-2013, 08:09 PM   PM User | #6
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
The XML schema you were given is not well-formed. I checked it in XML Copy Editor. To get things right the schema S/B:
Code:
<?xml version="1.0"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xml">

<xs:element name="equipment">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="f"> <!-- Flatbed -->
<xs:complexType>
<xs:attribute name="b-train" type="xs:boolean" default="false"></xs:attribute> <!-- B-train -->
<xs:attribute name="sides" type="xs:boolean" default="false"></xs:attribute> <!-- with Sides -->
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Next type="xs:boolean" gives problems because we need to write things out in html "xs:string" would be a lot nicer.

Here is a fast transfer from xml to html in php, but I do not understand how your going to do a look up with the info you have supplied.
Code:
<?php
$xmlString = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<equipment>
  <choice>
    <f b-train="true" sides="true">Flatbed</f>
  </choice>
</equipment>
XML;

$xmldata = simplexml_load_string($xmlString);

foreach($xmldata->choice as $item)
{
	echo "<h1>Equipment Types</h1>";
	echo '<span><input type="checkbox" name="equipment" value="flatbed">'.$item->f.'</span>';
	echo "<br />.......";
	echo "<h1>Equipment Specifications</h1>";
	if($item->f["b-train"] == "true"){
		echo '<label><input type="checkbox" name="specs" value="btrain">B-Train Flatbed</label><br>';
	}else{
		echo "No b-trains<br>";
	}

	if($item->f["sides"] == "true"){
		echo '<label><input type="checkbox" name="specs" value="sides">With Sides</label>';
	}else{
		echo "No sides<br>";
	}
}
?>
$xmlString is the xml based on the schema
sunfighter is offline   Reply With Quote
Users who have thanked sunfighter for this post:
Rcoleman25 (02-10-2013)