is there direct convert element object htmloption object? let's suppose have xml:
<?xml version='1.0'?> <options> <option value="1">hello1</option> <option value="2">hello2</option> </options>
i want insert each option in select
is there way convert these xml option directly or have navigate xml information need , create new option , add option select? like:
var options = xmlcode.getelementsbytagname('option'); for(var = 0; < options.length; i++){ selectbox.add(options[i]); }
as native code nice ^^ note: don't want use libraries or frameworks. want learn , myself.
xslt made xml html conversion. trick:
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="select2option.xml" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:html="http://www.w3.org/1999/xhtml" > <xsl:output method="html" encoding="utf-8" indent="yes" standalone="yes" media-type="text/html" omit-xml-declaration="yes" doctype-system="about:legacy-compat" /> <html:options> <html:option name="foo">bar</html:option> </html:options> <xsl:template match="xsl:stylesheet"> <xsl:apply-templates/> </xsl:template> <xsl:template match="/"> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template match="html:options"> <select> <xsl:apply-templates /> </select> </xsl:template> <xsl:template match="html:option"> <option name="@name"> <xsl:apply-templates /> </option> </xsl:template> </xsl:stylesheet>
Comments
Post a Comment