Click here to Skip to main content
15,924,367 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionReading XML file with C# Pin
Cyberdudes24-Nov-05 2:48
Cyberdudes24-Nov-05 2:48 
AnswerRe: Reading XML file with C# Pin
Christian Graus24-Nov-05 17:08
protectorChristian Graus24-Nov-05 17:08 
AnswerRe: Reading XML file with C# Pin
T1TAN2-Dec-05 13:41
T1TAN2-Dec-05 13:41 
AnswerRe: Reading XML file with C# Pin
Cyberdudes4-Dec-05 21:46
Cyberdudes4-Dec-05 21:46 
Questionhow to check element exists or not???? Pin
Sushant_Mathur23-Nov-05 2:02
Sushant_Mathur23-Nov-05 2:02 
AnswerRe: how to check element exists or not???? Pin
Denevers10-Dec-05 9:42
Denevers10-Dec-05 9:42 
QuestionXML digital signature processing rules and syntax Pin
Colin Angus Mackay22-Nov-05 6:03
Colin Angus Mackay22-Nov-05 6:03 
QuestionHow to read attribute of an element Pin
oohungoo20-Nov-05 16:48
oohungoo20-Nov-05 16:48 
I have an xml file like this:

======================= a.xml====================
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="a.xsl"?>
<cricket>
<player id="1" age="23">
<name prefix="mr">Hung</name>
<catches>250</catches>
<no_100>23</no_100>
<no_50>34</no_50>
</player>
<player id="2" age="24">
<name prefix="mr">Thanh</name>
<catches>234</catches>
<no_100>13</no_100>
<no_50>54</no_50>
</player>
<player id="3" age="25">
<name prefix="ms">Tuan</name>
<catches>432</catches>
<no_100>11</no_100>
<no_50>33</no_50>
</player>
<player id="4" age="20">
<name prefix="mr">Hoa</name>
<catches>333</catches>
<no_100>50</no_100>
<no_50>20</no_50>
</player>
<player id="5" age="21">
<name prefix="ms">Dzuy</name>
<catches>32</catches>
<no_100>34</no_100>
<no_50>26</no_50>
</player>
</cricket>

=================================================

and an xsl to display this xml file like this:

========================== a.xsl =====================
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<title>Test</title>
</head>
<body>
<table>
<tr>
<th>Player</th>
<th>No. of 50's</th>
<th>No. of 100's</th>
<th>No. of catches</th>
</tr>
<xsl:for-each select="cricket/player" order-by="name">
<tr>
<td><xsl:value-of select="name" /></td>
<td><xsl:value-of select="no_50" /></td>
<td><xsl:value-of select="no_100" /></td>
<td><xsl:value-of select="catches" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

=======================================================

The output will be like this:

Player 50's 100's Catches
Dzuy 26 34 32
Hoa 20 50 333
Hung 34 23 250
Thanh 54 13 234
Tuan 33 11 432

Now I would like to display the information of players include the id of them, like this:

ID Player 50's 100's Catches
1 Dzuy 26 34 32
2 Hoa 20 50 333
3 Hung 34 23 250
4 Thanh 54 13 234
5 Tuan 33 11 432

but I dont know how to read the attributes from player element. Any suggestion?
If I want to sort or use if statement depend on attribute (age>23 or id must be under 4 ect...), how to do that?
And how can I read attributes of elements that is read inside for-each statement, for example, attribute prefix of name element

If I want to show total number of players, how to do that?
AnswerRe: How to read attribute of an element Pin
Sushant_Mathur22-Nov-05 0:54
Sushant_Mathur22-Nov-05 0:54 
QuestionDyanamic menu using XML Pin
Shaji Raghavan19-Nov-05 23:47
Shaji Raghavan19-Nov-05 23:47 
Questionunparsed external entity question Pin
DJS817-Nov-05 12:31
DJS817-Nov-05 12:31 
QuestionRegarding CSS Pin
gauravbajaj15-Nov-05 0:37
gauravbajaj15-Nov-05 0:37 
Questionforce XML to get validated against an XSD schema? Pin
Roman Nurik13-Nov-05 18:01
Roman Nurik13-Nov-05 18:01 
QuestionHow to use &quot;&amp;nbsp;&quot; in *.xsl file Pin
oohungoo13-Nov-05 16:15
oohungoo13-Nov-05 16:15 
AnswerRe: How to use &amp;amp;amp;quot;&amp;amp;amp;amp;nbsp;&amp;amp;amp;quot; in *.xsl file Pin
Sushant_Mathur14-Nov-05 0:33
Sushant_Mathur14-Nov-05 0:33 
Questionnewbie needs xsl help Pin
dunbshy11-Nov-05 5:57
dunbshy11-Nov-05 5:57 
AnswerRe: newbie needs xsl help Pin
Sushant_Mathur14-Nov-05 0:23
Sushant_Mathur14-Nov-05 0:23 
QuestionConnecting Applications together Pin
kourvoisier11-Nov-05 4:26
kourvoisier11-Nov-05 4:26 
AnswerRe: Connecting Applications together Pin
Curtis Schlak.24-Nov-05 14:57
Curtis Schlak.24-Nov-05 14:57 
QuestionDifferentiate XML files with OpenFileDialog Pin
softplanner11-Nov-05 3:31
softplanner11-Nov-05 3:31 
QuestionPassing a xml object in C# Pin
pavan bhatara8-Nov-05 0:17
pavan bhatara8-Nov-05 0:17 
QuestionXML nomenclature/structure question Pin
Vikram A Punathambekar6-Nov-05 19:56
Vikram A Punathambekar6-Nov-05 19:56 
AnswerRe: XML nomenclature/structure question Pin
Shog922-Nov-05 6:51
sitebuilderShog922-Nov-05 6:51 
QuestionCan't parse SOAP with XPath Pin
Zhornyk5-Nov-05 3:19
Zhornyk5-Nov-05 3:19 
QuestionVBA / XML Pin
stevenho2-Nov-05 12:13
stevenho2-Nov-05 12:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.