How i'can Count nodes in XML?

Discussion in 'XML' started by Diodak, Apr 13, 2004.

  1. Diodak

    Diodak Guest

    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)
    Diodak, Apr 13, 2004
    #1
    1. Advertising

  2. "Diodak" <> wrote in message
    news:c5hck6$hfs$...
    > 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
    Dimitre Novatchev [MVP XML], Apr 13, 2004
    #2
    1. Advertising

  3. Diodak

    GIMME Guest

    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:eek:utput method='html' encoding='ISO-8859-1' indent="yes"/>
    <xsl:template match="/">
    <xsl:value-of select="count(/article/txt)"/>
    </xsl:template>
    </xsl:stylesheet>
    GIMME, Apr 13, 2004
    #3
  4. Diodak

    Diodak Guest

    *******************************************
    TNX for the solution but this in IE5 don't work correctly
    maybe some other solution help ?

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


    Uzytkownik "GIMME" <> napisal w wiadomosci
    news:...
    > 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:eek:utput method='html' encoding='ISO-8859-1' indent="yes"/>
    > <xsl:template match="/">
    > <xsl:value-of select="count(/article/txt)"/>
    > </xsl:template>
    > </xsl:stylesheet>
    Diodak, Apr 14, 2004
    #4
  5. Diodak

    Gadrin77 Guest

    "Diodak" <> wrote in message news:<c5ji8r$cdq$>...
    > *******************************************
    > 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
    Gadrin77, Apr 15, 2004
    #5
  6. Diodak

    Diodak Guest

    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>
    Diodak, Apr 18, 2004
    #6
  7. "Diodak" <> wrote in message
    news:c5tpea$gai$...
    > 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>
    >
    >
    >
    Dimitre Novatchev [MVP XML], Apr 18, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. asd
    Replies:
    3
    Views:
    428
    Arnaud Berger
    May 23, 2005
  2. gavnosis
    Replies:
    0
    Views:
    500
    gavnosis
    Aug 2, 2003
  3. Timo Nentwig

    selecting nodes between other nodes

    Timo Nentwig, Jun 16, 2004, in forum: XML
    Replies:
    1
    Views:
    391
    Patrick TJ McPhee
    Jun 17, 2004
  4. Johnny Ooi

    Looking A Nodes From Within Nodes

    Johnny Ooi, Nov 13, 2004, in forum: XML
    Replies:
    10
    Views:
    644
    Johnny Ooi
    Nov 14, 2004
  5. th3dude
    Replies:
    0
    Views:
    423
    th3dude
    Jan 3, 2007
Loading...

Share This Page