Hi David
From: "David Leuschner" <[EMAIL PROTECTED]>
> as there are no hasElement(...) or 'hasAttribute(...) methods in
> org.dom4j.Element I was wondering which is the best method to check if an
> element or attribute exists?
You could try this
Element parent = ...;
if ( parent.element( "foo" ) != null ) {
// has element called "foo"
}
if ( parent.attribute( "bar" ) != null ) {
// has attribute called "bar"
}
Or you can use a fully qualified name also.
QName foo = QName.get( "my:foo", "www.acme.com/something" );
if ( parent.element( foo") != null ) {
// has element with local name "foo" and the right namespace URI
}
QName bar = QName.get( "my:bar", "www.acme.com/something/else" );
if ( parent.attribute( bar ) != null ) {
// has attribute with local name "bar" and the right namespace URI
}
Note that when comparing QNames together, only the local name (the bit
without the namespace prefix) and the namespace URIs are compared.
James
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user