Hello the code is as followed:
<?xml version="1.0"?>
<wddxPacket version="1.0">
<header/>
<data>
<array length="2">
<struct type="coldfusion.server.ConfigMap">
<var name="XXXXX">
<struct type="coldfusion.server.ConfigMap">
<var name="disable"><boolean value="false"/></var>
<var name="alter"><boolean value="true"/></var>
<var name="username"><string>username1</string></var>
etc.
The code continues with 1000s of username values. I would like to create a loop that selects each username. so far my code for selecting each username looks like this.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select='wddxPacket/data/array/struct[@type="coldfusion.server.ConfigMap"]
/var/struct[@type="coldfusion.server.ConfigMap"]/var/@name'>
<xsl:value-of select="username"/>,
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I would like my output to look something like: username1,username2,username3,username4....The issue I am facing is my output is either empty or when I change the code to where the value-of select = "@name" I just get an output of username,username,username...
Thanks for any help!
At the moment, you are looping over the @name
attributes of all var
elements. If you only want the "username" ones, change it to this...
<xsl:for-each select='wddxPacket/data/array/struct[@type="coldfusion.server.ConfigMap"]
/var/struct[[@type="coldfusion.server.ConfigMap"]
/var[@name="username"]'>
Then, to get the user name, you can just do this...
<xsl:value-of select="string"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.