Jump to content

Read data from XML file


jle

Recommended Posts

Hi All,I have part of the xsl is defined as below:and now I want to have another array which has both wx_d and wx_c but the wx_name must be sorted.So what should I do. Thanks for the helpJP.var endpointNames_d = new Array();<xsl:for-each select="appwx_l/wx_l/wx_d"> <xsl:text>endpointNames_d[</xsl:text><xsl:value-of select="position()-1"/><xsl:text>]</xsl:text> = "<xsl:value-of select="wx_name"/>,<xsl:value-of select="wx_id"/>"; </xsl:for-each>var endpointNames_c = new Array();<xsl:for-each select="appwx_l/wx_l/wx_c"> <xsl:text>endpointNames_c[</xsl:text><xsl:value-of select="position()-1"/><xsl:text>]</xsl:text> = "<xsl:value-of select="wx_name"/>,<xsl:value-of select="wx_id"/>"; </xsl:for-each>

Link to comment
Share on other sites

You can use xsl:sort to do sorting based on a certain node-set, like so:var endpointNames_c = new Array();

<xsl:for-each select="appwx_l/wx_l/wx_c"><xsl:sort select="wx_name"/>endpointNames_c[<xsl:value-of select="position()-1"/>] = "<xsl:value-of select="wx_name"/>,<xsl:value-of select="wx_id"/>";</xsl:for-each>

(I've removed the <xsl:text/> elements, as they are all redunant)

Link to comment
Share on other sites

You can use xsl:sort to do sorting based on a certain node-set, like so:var endpointNames_c = new Array();
<xsl:for-each select="appwx_l/wx_l/wx_c"><xsl:sort select="wx_name"/>endpointNames_c[<xsl:value-of select="position()-1"/>] = "<xsl:value-of select="wx_name"/>,<xsl:value-of select="wx_id"/>";</xsl:for-each>

(I've removed the <xsl:text/> elements, as they are all redunant)

Hi,I would like to have the third array which has both wx_c and wx_d. The third array should have the values of first array (endpointNames_d) and second array(endpointNames_c). How can I get the third array which has values of first array+ second array.Thanks,JP
Link to comment
Share on other sites

You can have the XPath expression in the for-each statement select two node-sets with the "|" operator, like:

<xsl:for-each select="appwx_l/wx_l/wx_d|appwx_l/wx_l/wx_c">

Link to comment
Share on other sites

You can have the XPath expression in the for-each statement select two node-sets with the "|" operator, like:
<xsl:for-each select="appwx_l/wx_l/wx_d|appwx_l/wx_l/wx_c">

Hi,Sorry it didn't work! Is there any other way.to read the data from two node-sets.Thanks,JP
Link to comment
Share on other sites

Hi,Sorry it didn't work! Is there any other way.to read the data from two node-sets.Thanks,JP
Hi All,Thanks! It worked. It is my mistake I forgot the ">" at the end of string below.It didn't complain anything related to syntax but it didn't work.After I added the ">" to this string as below then It worked.Thanks,JP<xsl:for-each select="appwx_l/wx_l/wx_d|appwx_l/wx_l/wx_c">
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...