xml


XPath: Select node based on depth of descendant node type


I need to return the string "A1" or the string "A2" dependent upon the maximum depth of the "B" nodes beneath their containing nodes:
<xmlDoc>
<A>A1
<B>
<B>
<B>
</B>
</B>
</B>
<B>
</B>
</A>
<A>A2
<B>
<B>
</B>
</B>
<B>
<B>
</B>
</B>
</A>
</xmlDoc>
The descendant axis does not seem appropriate to determine the "depth" of the B nodes (Ex: /xmlDoc/A[count(descendant::B)>2]). The "A" node containing the string "A1" has a maximum "B" node depth of 3 but seems to have 4 "descendant" "B" nodes...
How would one construct an XPath expression to return the string "A1" based upon the "3 deep" occurrence of the "B" nodes in the first "A" node?
Descendant counts all children of the node. If you want chain of B nodes, write it so
/xmlDoc/A[B[B[B]]]

Related Links

How to add CVS informations in a JSP xml format to view in the source
Problem with SimpleDOM and sortedXPath
How do I include a Map of Strings as attributes in an xml tag using Scala?
Trying to add to a toolbar and menubar in KDevelop 4
Is there a XML Schema validation library that supports the default attribute value?
How would I increment the (version) value of an XML element using AWK?
help with xml transformation
Problems with “select yn in case”
XSD: how to use 'unique' & 'key'/'keyref' with element values?
dbms_xmlgen.getxml - How to set a date format
What is an XML processing instruction, and why is there so little information about them?
XML Package error in 2.12, but not 2.10
Cocoa: Loading a XML File (array);
Which XML serialization library for Scala?
Recursion between different methods of the same multimethod
xsltproc very slow processing HTML piped through tidy

Categories

HOME
batch-file
assembly
dns
alexa-skills-kit
mjml
hessian
saml-2.0
requirements
devise
aws-cli
simulink
lanczos
modal-dialog
little-proxy
project-intu
why3
redis-sentinel
opengl-es-3.0
jxl
openbugs
google-form
selenium-ide
shared-libraries
atlassian
do-while
azure-powershell
dreamweaver
solrcloud
undertow
springfox
squashfs
babel
exploit
tosca
perlbrew
fat
amazon-quicksight
outliers
winexe
errbot
anki
testbed
kodi
openwhisk
sharding
fiware-cygnus
roblox
raft
bc
azure-arm
postgresql-8.4
subclipse
placeholder
wc
vaadin-charts
optimizely
plan-9
geotiff
google-cse
java-bytecode-asm
boxing
mach-o
cd-burning
jtree
redistributable
pacemaker
lrs
watch-os-2
neon
mongodb-php
wso2developerstudio
installshield-2010
jtwig
nss
bizagi
gcloud-ruby
createprocess
nupic
libvlc
boomerang
java-money
ess
android-launcher
lasso
sql-server-data-tools
typeconverter
boost-program-options
ssis-data-flow
teaspoon
linkedin-jsapi
websphere-esb
git-repo
gwt-openlayers
android-usb
gd-graph
mysql-error-1044
diem
wp7test
insert-id
alice
asplinkbutton
argouml
web-notifications
intersect
onmousemove
jquery-blockui
adobe-media-server
predicatebuilder
ilasm
kqueue
jquery-address
procedures
non-clustered-index
duplex
build-environment
glui
interop-domino
entitykey

Resources

Encrypt Message