473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 13268

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mr_burns | last post by:
Hi, I am using the following function to access a nodes value from an XML file. It works fine until it discovers a empty tag. I would like to have the option of leaving some tags empty for my...
3
by: Andy Fish | last post by:
Hi, I'm trying to use <xsl:number> to generate a sequence number of all nodes that match a particular pattern, e.g: <xsl:template match="foo"> <xsl:copy> <xsl:attribute name="id"><xsl:number...
5
by: Jeroen Ceuppens | last post by:
I need to put a new node at the end of the tree, that end is not te lowest in de list but the deepest (the one with the most + before it) Node A Node 1 Node 2 Node 3 Node 4: Deepest Node B:...
0
by: andreas | last post by:
Bill, what are you doing? I see the methode count in vb.net and in vb.net express but not in vb.net 2003 int = treeview.nodes.count Int = treeview1.nodes(i).nodes.count
1
by: JS1 | last post by:
Hi there, How do I count the number of <Item> nodes for each <Message> in the following xml document? (Xml Document) <Message> <Order> <Item>1</Item> <Item>2</Item>
2
by: Norton Who | last post by:
Hi, Could I please ask if anyone could help me solve this problem in VS2003: I'm trying to count all the nodes that have a Checked state however this doesn't seem to be working for me. So...
0
by: rekhasc | last post by:
In my proj it will dynamically add the nodes, but i want to count the child nodes when i select the parent node ... it should display the number of child nodes in the form ... i will attach the prog...
10
by: John Rogers | last post by:
This code only counts the parent nodes or rootnodes in a treeview, how do you count all the nodes in a treeview? // one way int NodeCounter = 0; foreach (TreeNode currentNode in...
1
by: Derek Hart | last post by:
I wish to get a count of nodes in an xml file in vb.net, so I am using the following, as a simple example: MyCount = xmlNodePart.Current.Select.//MyNode/Record).Count I saw in some xml...
9
by: smarttechie | last post by:
Hii all please help its urgent i have developed an application in xsl. what i want to do is i m searching the xml file based on a search.and based on that search im creating one tree like...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.