Fromethe Javadoc
public Document parse(String uri)
throws SAXException,
IOException
Parse the content of the given URI as an XML document and return a new DOM Document object. An IllegalArgumentException is thrown if the URI is null null.
so the URI is provided as a Java String, not a 'uri' object.
public class aaa{
public static void main(String[] args)
{
try{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder parser = dbf.newDocumentBuilder();
//Document doc = parser.parse(new File("foo.xml")); // the XML document the content of which you want to print
Document doc = parser.parse(new URL("http://www.youtube.com/api2_rest?method=http://somthing&video_id=R98qC0fd_1w"));
String tagName = "siteurl"; // the tag name of the nodes, e.g. "siteurl" or "publisher"
org.w3c.dom.NodeList nodeList = doc.getElementsByTagName(tagName); // all of the nodes having the specified tag name
for (int i = 0; i < nodeList.getLength(); i++) {
System.out.println(tagName+" "+nodeList.item(i).getTextContent().trim());
}
}
catch(Exception e){System.out.println(e);}
}
forgot to say its a xml parse
Message was edited by:
aaa801