java - Reading XML drom webpage returning null -


i using following code read xml webpage. have mentioned public url here cant mention project url:

`string g1="http://www.w3schools.com/xml/note.xml";      documentbuilderfactory dbfactory=documentbuilderfactory.newinstance();     documentbuilder dbuilder=dbfactory.newdocumentbuilder();     document doc=dbuilder.parse(g1);` 

but receiving value of doc null.

do :-

    string urlstring = "http://www.w3schools.com/xml/note.xml";     url url = new url(urlstring);      documentbuilderfactory dbfactory=documentbuilderfactory.newinstance();         documentbuilder dbuilder=dbfactory.newdocumentbuilder();     document doc = dbuilder.parse(url.openstream());     nodelist descnodes = doc.getelementsbytagname("note");       for(int i=0; i<descnodes.getlength();i++)      {          system.out.println(descnodes.item(i).gettextcontent());      } 

output:-

    tove     jani     reminder     don't forget me weekend! 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -