[R] xmlAttrs and problems with reading node attributes of XML file (b ug?)

From: Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI_at_saic.com>
Date: Sat 28 May 2005 - 00:14:57 EST


Hi,

Consider the following code:

	  require(XML)
	  xmlFile = paste( "<?xml version=\"1.0\"
encoding=\"ISO-8859-1\"?>\n", 
	            "<mzXML xmlns=\"a\" xmlns:xsi=\"b\"
xsi:schemaLocation=\"c\">\n",
	            "<parentFile a=\"a\" b=\"b\" />\n",
	            "</mzXML>\n")
	  cat(xmlFile)
	  
	  a = function(x,...){
	    cat("Attributes of ", xmlName(x), ": "); 
	    print(xmlAttrs(x));
	    cat("\n"); 
	    NULL
	  }
	  
	  xmlTreeParse(file=xmlFile, asText=TRUE,
handlers=list("startElement"=a) )

And its output:

<?xml version="1.0" encoding="ISO-8859-1"?>
<mzXML xmlns="a" xmlns:xsi="b" xsi:schemaLocation="c">
<parentFile a="a" b="b" />
</mzXML>

	Attributes of  parentFile :   a   b 
	                                     "a" "b" 

	Attributes of  mzXML : schemaLocation 
	                                  "c" 

It seems to me that XML parser was able to correctly list all the attributes of the "parentFile" node but it failed on "mzXML" node. Am I missusing the functions somehow or is it a bug? Attribute names in "mzXML" node are part of mzXML file format and can not be changed (removing all ':' would fix the problem) and I would like to store than so whan I write mzXML file I have the same header.

Jarek

====================================================\=======

 Jarek Tuszynski, PhD.                           o / \ 
 Science Applications International Corporation  <\__,|  
 (703) 676-4192                                   ">   \
 Jaroslaw.W.Tuszynski@saic.com                     `    \



	[[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat May 28 00:27:24 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:11 EST