Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here is an example xml webpage I am accessing and parsing with XML package in R.
I am interested in accessing the following information.
<comment type="function"> and <comment type="subcellular location">,
Here is the code I am running but it extract the first comment node regardless of its attributes or type (function or subcellular location ). How can I specifically extract function and subcellular locatio. Further what if there are multiple function attributes in same XML file. How can I specify the number (order) in they appears.

What I have tried:

C#
web <-"http://www.uniprot.org/uniprot/Q13651.xml"
html <- getURL(web, followlocation = TRUE)
doc = xmlInternalTreeParse(html,asText=T, useInternal = TRUE)
top = xmlRoot(doc, skip = F)
xmlSApply(top[[1]][["comment"]], xmlValue)

text 
"Receptor for IL10; binds IL10 with a high affinity."
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900