Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How i'can Count nodes in XML?

Reply
Thread Tools

How i'can Count nodes in XML?

 
 
Diodak
Guest
Posts: n/a
 
      04-13-2004
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)


 
Reply With Quote
 
 
 
 
Dimitre Novatchev [MVP XML]
Guest
Posts: n/a
 
      04-13-2004

"Diodak" <(E-Mail Removed)> wrote in message
news:c5hck6$hfs$(E-Mail Removed)...
> 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


 
Reply With Quote
 
 
 
 
GIMME
Guest
Posts: n/a
 
      04-13-2004
Even I know that...

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xslreserve-space elements="*"/>
<xslutput method='html' encoding='ISO-8859-1' indent="yes"/>
<xsl:template match="/">
<xsl:value-of select="count(/article/txt)"/>
</xsl:template>
</xsl:stylesheet>
 
Reply With Quote
 
Diodak
Guest
Posts: n/a
 
      04-14-2004
*******************************************
TNX for the solution but this in IE5 don't work correctly
maybe some other solution help ?

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


Uzytkownik "GIMME" <(E-Mail Removed)> napisal w wiadomosci
news:(E-Mail Removed) om...
> Even I know that...
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"

version="1.0">
> <xslreserve-space elements="*"/>
> <xslutput method='html' encoding='ISO-8859-1' indent="yes"/>
> <xsl:template match="/">
> <xsl:value-of select="count(/article/txt)"/>
> </xsl:template>
> </xsl:stylesheet>



 
Reply With Quote
 
Gadrin77
Guest
Posts: n/a
 
      04-15-2004
"Diodak" <(E-Mail Removed)> wrote in message news:<c5ji8r$cdq$(E-Mail Removed)>...
> *******************************************
> 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
 
Reply With Quote
 
Diodak
Guest
Posts: n/a
 
      04-18-2004
I find other solution and this work correctly in MSIE5 ;]
//file XSL

<?xml version='1.0'?>
<xsl:stylesheet xmlnssl="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>



 
Reply With Quote
 
Dimitre Novatchev [MVP XML]
Guest
Posts: n/a
 
      04-18-2004

"Diodak" <(E-Mail Removed)> wrote in message
news:c5tpea$gai$(E-Mail Removed)...
> I find other solution and this work correctly in MSIE5 ;]
> //file XSL
>
> <?xml version='1.0'?>
> <xsl:stylesheet xmlnssl="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>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
finding nodes that don't match other nodes mlybarger@gmail.com XML 2 01-27-2005 07:26 PM
Looking A Nodes From Within Nodes Johnny Ooi XML 10 11-14-2004 06:55 PM
selecting nodes between other nodes Timo Nentwig XML 1 06-17-2004 04:54 AM
Reality check: Is it sensible to link XML nodes to other XML nodes in the same file? gavnosis XML 0 08-02-2003 08:22 AM



Advertisments