472,374 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 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 13210

"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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.