xslt - XSL - Display XML tags based on parameter from PHP -
ive got problem displaying desired xml tags based on parameter. i'm new this.
xml example:
<car name="toyota"> <model nr="123" yeardate="2010"> <owner ssn="123456789" name="tom"/> <owned years="0" months="6"/> </model> </car> <car name="volvo"> <model nr="222" yeardate="2009"> <owner ssn="345364774" name="john"/> <owned years="0" months="8"/> </model> </car> <car name="fiat"> <model nr="333" yeardate="2010"> <owned years="0" months="0"/> </model> </car>
the problem want able choose car displayed based on html form made in php document. so, made form in php, sent value of post xsl document , want display car based on parameter value. also, notice car fiat not have owner. able value of post in xsl document, i'm not sure how go using parameter.
what imagine turning in to: lets toyota choosen in form,
car name=toyota model nr=123 yeardate=2010 owner ssn=123456789 name=tom owned years=0 months=6
i want include tag name attributes.
if you're using php, maybe don't need xsl. have @ simplexml.
<?php $xmlstring = '<root> <car name="toyota"> <model nr="123" yeardate="2010"> <owner ssn="123456789" name="tom"/> <owned years="0" months="6"/> </model> </car> <car name="fiat"> <model nr="333" yeardate="2010"> <owned years="0" months="0"/> </model> </car> </root>'; $xml = new simplexmlelement($xmlstring); foreach ($xml->children() $second_gen) { if ( (string) $second_gen['name'] == "toyota") { echo $second_gen->asxml(); } } ?>
Comments
Post a Comment