Forum Stats

  • 3,872,606 Users
  • 2,266,458 Discussions
  • 7,911,262 Comments

Discussions

How to display XML content in Text Field?

843834
843834 Member Posts: 49,972
edited Jul 25, 2001 1:05PM in Java Technology & XML
I want to have a XSL file to pick up the content of the XML file and fill it to an Input Text Field.

The following is my XML file: -
Profile.XML
-----------
<table>
<CompanyProfile>
<Name>ABC, Incorp</Name>
</CompanyProfile>
</table>

In my XSL file, the value of Name will be displayed in the text field
E.g. in my XSL file I have: -
<input type="text" name="NameText" size="50" maxlength="50" />

How do I insert the following into the field?
<xsl:value-of select="table/CompanyProfile/Name"/>

Comments

  • 843834
    843834 Member Posts: 49,972
    I want to have a XSL file to pick up the content of
    the XML file and fill it to an Input Text Field.

    The following is my XML file: -
    Profile.XML
    -----------
    <table>
    <CompanyProfile>
    <Name>ABC, Incorp</Name>
    </CompanyProfile>
    </table>

    In my XSL file, the value of Name will be displayed in
    the text field
    E.g. in my XSL file I have: -
    <input type="text" name="NameText" size="50"
    maxlength="50" />

    How do I insert the following into the field?
    <xsl:value-of select="table/CompanyProfile/Name"/>
    I think this is how you would do it. Use xsl:attribute to add an attribute to your input tag.
    <xsl:template match="foo">
     <input>
       <xsl:attribute name="name">
        <xsl:value-of select="table/CompanyProfile/Name" />
       </xsl:attribute>
      </input>
    </xsl:template>
    This should add an attribute to the <input> tag named "name" with a value determined by the xsl:value-of statement.

    Assuming your XPath value is correct, the result would be:
    <input name="ABC, Incorp">

    Hope this helps.

    Mike W.
  • 843834
    843834 Member Posts: 49,972
    Thanks Mike.

    I set the attribute to value instead of name: -
    <xsl:attribute name="value">

    It works great.
    Thanks again

    Albert KT Tan


This discussion has been closed.