[jdom-interest] problem with getChildren (probabely my understanding)

Dolf Andringa dolf.andringa at elcyion.nl
Sat Nov 19 09:57:41 PST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi All,

I've just started using jdom to write an application that creates a JDOM
object from an XML file, manipulates it and then feeds it to Xalan to do
XSLT processing. I'm running into a problem though. If I use the
getChildren method on my root Element, it correctly returns a list ofthe
root element's children. If I use getChildren with as the argument the
name of an element that occures multiple times as the child of the root
element, nothing is returned. A test is below(i'm using python as the
programming language with the jython interpreter so I can use java
classes from python, but it should be no different form using native java):

for member in doc.getRootElement().getChildren():
	if (member.getName()=="featureMember"):
		print member.getName()
print "\n\nAnd next:\n\n"		
for member in doc.getRootElement().getChildren("featureMember"):
		print member.getName()

The first loop correctly displays several times "featureMember"
but after the "And next: " nothing is displayed:

Parsing and transforming to JDOM succeeded.


featureMember
featureMember
featureMember
featureMember
featureMember
featureMember
featureMember


And next:


Shouldn't it be possible to use getChildren with a name argument to
return only the child elements with a specific name? Now I have to loop
through all the child elements to create a list of the child elements I
want. I'd rather get a list of those elements with just the getChildren
functioncall. The XML file I'm using is in the attachment. I hope
anybody can help me with this.
Thanks,

Dolf.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDf2eUKaTTNeXBMakRAjRcAJwNsMsFSINn/nElTM0yHz6XsrvkOACeLTNd
VwSvWT8VzGsGMBRymYxMUac=
=cE4/
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: G10.gml
Type: text/xml
Size: 28405 bytes
Desc: not available
Url : http://www.jdom.org/pipermail/jdom-interest/attachments/20051119/91f54579/G10.xml


More information about the jdom-interest mailing list