help with document builder / parser

is there a way to change this to a urlDocument doc = parser.parse(new File("foo.xml"));because when i doparse(new url("theres no methodsame with new file(new urlhelp please
[221 byte] By [aaa801a] at [2007-11-27 8:36:41]
# 1

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.

sabre150a at 2007-7-12 20:33:42 > top of Java-index,Java Essentials,Java Programming...
# 2

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

aaa801a at 2007-7-12 20:33:42 > top of Java-index,Java Essentials,Java Programming...
# 3
I have explained what is wrong - please read the Javadoc for the parse() methods.
sabre150a at 2007-7-12 20:33:42 > top of Java-index,Java Essentials,Java Programming...
# 4
o thanksdidnt read it properly
aaa801a at 2007-7-12 20:33:43 > top of Java-index,Java Essentials,Java Programming...