Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have an xml like below

<Envelope>
<Body>
<response>
<timestamp>
<status>
<Objectstatus>
<class>stats</class>
<Adminstate>disabled</Adminstate>
<name>abc</name>
</objectstatus>
<objectstatus>
<class>Policy</class>
<adminstate>enabled</adminstate>
<names>xyz</name>
</Objectstatus>

The response expected is stats,disabled,abc Policy,enabled,xyz

Could you please tell me how i can do it using a stylesheet.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
140 views
Welcome To Ask or Share your Answers For Others

1 Answer

First thing first, make sure your child nodes have all the same name (Adminstate or adminstate, etc...), remember that it is case sensitive.

I'm also assuming you would like a HTML output, here's what you could try:

 <xsl:for-each select="//Objectstatus">
   <p>
     <xsl:value-of select="./class"/>
     <xsl:text>,</xsl:text>
     <xsl:value-of select="./Adminstate"/>
     <xsl:text>,</xsl:text>
     <xsl:value-of select="./name"/>
   </p>
 </xsl:for-each>

Here's the output:

stats,disabled,abc Policy,enabled,xyz


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...