[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Fri Jul 29 15:41:01 UTC 2005
mwilkinson
Fri Jul 29 11:41:01 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv9241/MOBY/Client
Modified Files:
Central.pm
Log Message:
XML::LibXML documentation is crappy. Had to read the source to figure out the NamedNodeMap interface. Can now retrieve the value of the LSID attribute
moby-live/Perl/MOBY/Client Central.pm,1.104,1.105
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105
@@ -1975,28 +1975,15 @@
sub _nodeAttributeValue {
- # will get text of **all** child $node from the given $DOM
- # regardless of their depth!!
my ( $DOM, $node, $attr ) = @_;
+ return "" unless $attr;
my $x = $DOM->getElementsByTagName($node);
- unless ( $x->get_node(1) ) { return }
+ unless ( $x->get_node(1) ) { return "" }
my $n = $x->get_node(1);
- my @att = $n->attributes($attr);
- my $atval;
- if (scalar(@att)){
- $atval = $attr->getValue;
- }
- my @child = $x->get_node(1)->childNodes;
- my $content;
- foreach (@child) {
-
- #print getNodeTypeName($_), "\t", $_->toString,"\n";
- next
- unless ( ( $_->nodeType == TEXT_NODE )
- || ( $_->nodeType == CDATA_SECTION_NODE ) );
- $content = $_->textContent;
- }
- return $content;
+ my $nodemap = $n->attributes($attr); # XML::LibXML::NamedNodeMap - the worst documented (i.e. undocumented) piece of code ever written! You have to read the source to figure out the interface...
+ my $attrnode = $nodemap->getNamedItem($attr);
+ my $attrval = $attrnode?($attrnode->value):"";
+ return $attrval;
}
sub _nodeRawContent {
More information about the MOBY-guts
mailing list