Header Ad

Friday, August 17, 2007

Reading XML from another Site using Java code

import="com.sun.org.apache.xerces.internal.util.URI"
import="java.io.InputStream"
import="java.net.URL"
import="javax.xml.parsers.DocumentBuilderFactory"
import="javax.xml.parsers.DocumentBuilder"
import="org.w3c.dom.Document"
import="org.w3c.dom.NodeList"
import="org.w3c.dom.NamedNodeMap"
import="org.w3c.dom.Node"

URL url= new URL("www.google.com");
InputStream in=url.openStream();
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
DocumentBuilder builder=factory.newDocumentBuilder();
Document document=builder.parse(in);

If you want to get retrive entire node list that can be done by

NodeList nodeList=document.getElementsByTagName("NameofTheNode");

By these all the node will come in that Node List.
If you want to retrive the attributes with in that Node,that can be done by

Node node= nodeList.item(indx);
NamedNodeMap nnm=node.getAttributes();
String href=nnm.getNamedItem("AttributeNamewithinthatNode").getNodeValue();

Saturday, August 11, 2007

We can show Social Networking Site Results in our site by WINK API

URL:www.wink.com

We have to create an account in WINK,accept terms and conitions of WINK for integrating.
Once these are accepted they will provide the code snippet. Copy code snippet and place in our site for tracking.



We have to provide domain url in order to get the code snippet.