c# - Xdocument.Load is failing -


i unable load xdocument.load unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.loadi unable load xdocument.load

   public void authornames(string uri)     {          credentialcache credentialcache = new credentialcache();         credentialcache.add(         new uri("https://www.restwebservicessite.com"),         "basic",         new networkcredential("userid", "pwd"));           httpwebrequest request = (httpwebrequest)webrequest.create(uri);         request.allowautoredirect = true;         request.preauthenticate = true;         request.credentials = credentialcache;         request.automaticdecompression = decompressionmethods.gzip;          try         {             using (httpwebresponse response = request.getresponse() httpwebresponse)             {                  xmlreader responsereader = xmlreader.create(response.getresponsestream());                  //xmldocument doc = new xmldocument();                  **xdocument docs = xdocument.load();**                 // responsereader.read();                 //xdocument docs = xdocument.load(response.getresponsestream());             list<string> books = docs.descendants("intel")           // not necessary, makes simpler         .select(x => new {            title = (string) x.element("title"),            author = x.element("intel_auth")            })       .select(x => new {            title = x.title,            firstname = (string) x.author.element("fname"),            middleinitial = (string) x.author.element("mname"),            lastname = (string) x.author.element("lname"),         })    .select(x => string.format("{0}: {1} {2} {3}",                            x.title,                            x.firstname, x.middleinitial, x.lastname))    .tolist();     (int = 0; < books.count; i++)    {     (int j = 0; j < books.count; j++)     {     response.write("--" + books[i] + "---" + books[j]);     }    } 

}

        }         catch (exception ex)         {             response.write("remote server returned error.");         }     } 

i unable load xdocument.load xml feed.

it's not clear exactly want, suspect it's this:

xdocument doc = ...; // want load this. // note: xml case-sensitive, 1 reason code failed before list<string> books = doc     .descendants("intel")     // not necessary, makes simpler     .select(x => new {                title = (string) x.element("title"),                author = x.element("intel_auth")             })     .select(x => new {                title = x.title,                firstname = (string) x.author.element("fname"),                middleinitial = (string) x.author.element("mname"),                lastname = (string) x.author.element("lname"),             });     .select(x => string.format("{0}: {1} {2} {3}",                                x.title,                                x.firstname, x.middleinitial, x.lastname))     .tolist(); 

this give list<string> each element "test 1: john m. pp".


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -