Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[bioontology-support] Parsing the BioPortal web service response

Paul R Alexander palexander at stanford.edu
Fri Jan 20 18:18:00 PST 2012


Pradnya,

You can use an XPath with the Document object in order to get nodes at a 
particular level of the DOM hierarchy. Here is some untested sample code 
for doing this using XML from the get terms service:
|XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression expr = xpath.compile("/success/data/classBean");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;|

Also, if you're more comfortable working with JSON then you can try our 
JSON support, which is currently in alpha. To get results in JSON, just 
add an "Accept: application/json" header to your request. This should 
work for all of the Ontology Management services (IE for BioPortal, but 
not Annotator or Resource Index).

Best,
Paul R Alexander
Web / UI Developer
NCBO BioPortal
Stanford Center for Biomedical Informatics Research


On 1/20/12 6:23 AM, Pradnya Gawade wrote:
>
> Hello,
>
> I am planning to integrate my web application with BioPortal by using 
> REST web services API and would like to know more about how people 
> parse the web service response from BioPortal.
>
> Some where I found the sample code to parse these xmls using DOM 
> parser which I am using right now and it works for simple cases but I 
> think it is not reliable because it is difficult to handle nested 
> elements and things like this with this way where you fetch the 
> elements using methods like /getElementsByTagName(String ..)./
>
> Some sample code is here:
>
> DocumentBuilderFactory docBuilderFactory = 
> DocumentBuilderFactory./newInstance/();
>
> DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
>
> Document doc = docBuilder.parse(uri);
>
> doc.getDocumentElement().normalize();
>
> NodeList listClassBean1 = doc.getElementsByTagName("classBean");
>
> //I am not able to specify the level of elements in the hierarchy I 
> want to go up to as in the BioPortal web service response, "classBean" 
> is at multiple levels. I am thinking there might be better ways to do 
> this may be using APIs like castor or some how making use of schema 
> files. However BioPortal say they do not provide schema files. Could 
> any body please provide any suggests as to how they are doing it? 
> Presently I am planning to take a look at castor to see how I can use 
> it with BioPortal web services.
>
> I will really appreciate the quick response from some body.
>
> - Pradnya
>
>
>
> _______________________________________________
> bioontology-support mailing list
> bioontology-support at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/bioontology-support
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/bioontology-support/attachments/20120120/45f664ba/attachment.html>


More information about the bioontology-support mailing list