469,275 Members | 1,871 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

How i'can Count nodes in XML?

How i'can Count nodes in XML?
1. how get count nodes our base in XML
for level <txt>
<article>
<txt>
<disc>aaaaaaa</disc>
<misc>bbbbbbb</misc>
<pict>bbbbbccc</pict>
</txt>
<txt>
<disc>sssss</disc>
<misc>dddddd</misc>
<pict>ffffffff</pict>
</txt>
</article>

Please give me some example or link to this solution (TNX)
Jul 20 '05 #1
6 13125

"Diodak" <di*****@poczta.onet.pl> wrote in message
news:c5**********@news.onet.pl...
How i'can Count nodes in XML?
1. how get count nodes our base in XML
for level <txt>
<article>
<txt>
<disc>aaaaaaa</disc>
<misc>bbbbbbb</misc>
<pict>bbbbbccc</pict>
</txt>
<txt>
<disc>sssss</disc>
<misc>dddddd</misc>
<pict>ffffffff</pict>
</txt>
</article>

Please give me some example or link to this solution (TNX)

Learn XPath and use it.

Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
Jul 20 '05 #2
Even I know that...

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:preserve-space elements="*"/>
<xsl:output method='html' encoding='ISO-8859-1' indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="count(/article/txt)"/>
</xsl:template>
</xsl:stylesheet>
Jul 20 '05 #3
*******************************************
TNX for the solution but this in IE5 don't work correctly
maybe some other solution help ?

*******************************************
Uzytkownik "GIMME" <gi*******************@yahoo.com> napisal w wiadomosci
news:3f**************************@posting.google.c om...
Even I know that...

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:preserve-space elements="*"/>
<xsl:output method='html' encoding='ISO-8859-1' indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="count(/article/txt)"/>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #4
"Diodak" <di*****@poczta.onet.pl> wrote in message news:<c5**********@news.onet.pl>...
*******************************************
TNX for the solution but this in IE5 don't work correctly
maybe some other solution help ?

*******************************************


Here some VBScript using the DOM, I got off the web.
maybe someone can translate it into XSL/XSLT. You
should be able to insert your own counter.
Private Sub Dumpnode(nodename as MSXML.IXMLDOMNode, intlevel as Integer)

Dim nodattr as MSXML.IXMLDOMNode
Dim nodchild as MSXML.IXMLDOMNode

Debug.Print Space(intlevel); nodNode.NodeName; vbTab; nodNode.nodeValue

If Not nodNode.Attributes is Nothing Then
For Each nodAttr in nodNode.Attributes
Debug.Print Space(intlevel); nodNode.NodeName; vbTab; nodNode.nodeValue
Next
End If

For Each nodChild In nodNode.childNodes
DumpNode nodChild, intLevel +1
Next

End Sub
';initially called as DumpNode DomDocument, 0
Jul 20 '05 #5
I find other solution and this work correctly in MSIE5 ;]
//file XSL

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<script type="text/javascript">
function LICZ()
{
x=xml_base.recordset
document.write(" [ ")
document.write(x.recordcount)
document.write(" ] ")
}
</script>
</head>
<body>

<xml id="xml_base" src="file_xml.xml" async="false"></xml>
<script>LICZ()</script>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #6

"Diodak" <di*****@poczta.onet.pl> wrote in message
news:c5**********@news.onet.pl...
I find other solution and this work correctly in MSIE5 ;]
//file XSL

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
This is not XSLT but an old TR dialect that nowadays almost nobody uses.

Wake up.

<xsl:template match="/">
<html>
<head>
<script type="text/javascript">
function LICZ()
{
x=xml_base.recordset
document.write(" [ ")
document.write(x.recordcount)
document.write(" ] ")
}
</script>
</head>
<body>

<xml id="xml_base" src="file_xml.xml" async="false"></xml>
<script>LICZ()</script>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by mr_burns | last post: by
5 posts views Thread by Jeroen Ceuppens | last post: by
reply views Thread by andreas | last post: by
1 post views Thread by JS1 | last post: by
2 posts views Thread by Norton Who | last post: by
10 posts views Thread by John Rogers | last post: by
1 post views Thread by Derek Hart | last post: by
9 posts views Thread by smarttechie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.