Reading xml from aspx webpage

We need to read the data from the aspx page. When we invoke the page with the query string, it returns an XML document with data that matches the query string.

We have an XSD that corresponds to xml return.

I think we can read the XML document from the HTTP response. Will this work?

How can we associate XML with XSD so that we can process the XML document as if it were strongly typed?

Thanks,

Shiraz

Update:

Found this link on how to deserialize

XML deserialization for objects in C #

+3
source share
1 answer

, , XML- ( try/catch , !):

HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "POST";  // or GET - depends 

myRequest.ContentType = "text/xml; encoding=utf-8";
myRequest.ContentLength = data.Length;

using (Stream reqStream = myRequest.GetRequestStream())
{
  // Send the data.
  reqStream.Write(data, 0, data.Length);
  reqStream.Close();
}

// Get Response
WebResponse myResponse;

myResponse = myRequest.GetResponse();
XmlDocument _xmlDoc = new XmlDocument();

using (Stream responseStream = myResponse.GetResponseStream())
{
   _xmlDoc.Load(responseStream);
}   

GET POST, - GET .

XML XmlDocument, XML, , XSD-.

→ XML . , .

+3

Source: https://habr.com/ru/post/1718022/


All Articles