I'm trying to figure out a way to utilize a PHP script that will:
So, if I had an XML file that went like this:
<profile>
Hello, my name is <name></name>. I am <age></age> years old. I live in <place></place>
</profile>
Upon clicking a link to that file, PHP would generate a form like so:
<form>
Name:
Age:
Place:
</form>
Then upon completing and submitting the form (let's say the person is Joel, 25, from Boston), the following would be written to the screen:
Hello, my name is Joel. I am 25 years old. I live in Boston.
Any code or points to good tutorials would be appreciated.
THX
E.
You should use XSLT for this..
With browser:
xml:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<profile>
Hello, my name is <name></name>. I am <age></age> years old. I live in <place></place>
</profile>
xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="profile">
<form>
<xsl:for-each select="child::*">
<label>
<xsl:value-of select="name()"/>:
<input name="{name()}" type="text" />
</label>
<br />
</xsl:for-each>
</form>
</xsl:template>
</xsl:stylesheet>
output:
<form>
<label>name: <input type="text" name="name"></label><br />
<label>age: <input type="text" name="age"></label><br />
<label>place: <input type="text" name="place"></label><br />
</form>
There is an xsl extension for php you can use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With