473,386 Members | 2,129 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.

has children or no ?


Hi,
how could I find out a node has childern or no using xpath ?

Thanks
Nov 12 '05 #1
2 3635
You can test it like using the not(expr) function:

Sample XSLT:
======================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:if test="not(/*/*)">not any children node here</xsl:if>
<xsl:if test="(/*/*)">there is at least a child node</xsl:if>
</xsl:template>
</xsl:stylesheet>
======================================

transform it with either:
<doc/>
either:
<doc><child>hello world</child></doc>

so you see the differents output.

Hope this help.

Gauthier Segay
C# newbie wrote:

Hi,
how could I find out a node has childern or no using xpath ?

Thanks


Nov 12 '05 #2
Thanks. Your previous answer made my day :)

"Gauthier" <ga********@ifrance.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
You can test it like using the not(expr) function:

Sample XSLT:
======================================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:if test="not(/*/*)">not any children node here</xsl:if>
<xsl:if test="(/*/*)">there is at least a child node</xsl:if>
</xsl:template>
</xsl:stylesheet>
======================================

transform it with either:
<doc/>
either:
<doc><child>hello world</child></doc>

so you see the differents output.

Hope this help.

Gauthier Segay
C# newbie wrote:

Hi,
how could I find out a node has childern or no using xpath ?

Thanks

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Todd Cary | last post by:
In my previous post, I stated that some JavaScript I inherited does not work in Firefox but does work in IE 6 . I have now isolated a line where it fails in Firefox; the line with the property of...
6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
17
by: eric.nave | last post by:
What is the correct way to find all the form elements in a particular div? I'd like to be able to loop through them and disable them. For example: <form> <div id="div1"> <input type=text...
0
by: Walt Borders | last post by:
Hi, My problem: Merging two datasets deletes parent elements, preserves all children. I've created two dataSets. Each use the same schema, parent-child nested tables. The first dataSet is...
1
by: Marius Groenendijk | last post by:
Dear Group, I have a MDI with children which may be editing data. If a MDI child closes its Closing handler asks a question 'exit w/out saving?'. On closing the MDI its pops a question 'Exit...
2
by: Pucca | last post by:
I'm building a treeview and a list view. I need to know when I reached the end of the tree nodes, which means that node or directory entry has no children. Is there a property or method in...
7
by: Thierry Lam | last post by:
I have the follownig codes: <html> <head> <title>Simple doc</title> </head> <body> <script type="text/javascript"> function greet() {
3
by: Andrej Pavlovic | last post by:
Hi, Please look at the following HTML snippet: <body> some text <p>more text</p> even more text </body>
10
by: qwertycat | last post by:
I'm new to multi-process programming, should one avoid forking children from children of a parent? I'd like to spawn 10 children from the parent and each of those children spawns another 5...
9
MrPickle
by: MrPickle | last post by:
I have a structure like so: struct node { float x, y, z; std::vector<node> children; }; and I want to loop through all the node's children, then all the children's children then all the...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.