• <bdo id='Nt7dC'></bdo><ul id='Nt7dC'></ul>
  1. <small id='Nt7dC'></small><noframes id='Nt7dC'>

    1. <tfoot id='Nt7dC'></tfoot>
    2. <legend id='Nt7dC'><style id='Nt7dC'><dir id='Nt7dC'><q id='Nt7dC'></q></dir></style></legend>
      <i id='Nt7dC'><tr id='Nt7dC'><dt id='Nt7dC'><q id='Nt7dC'><span id='Nt7dC'><b id='Nt7dC'><form id='Nt7dC'><ins id='Nt7dC'></ins><ul id='Nt7dC'></ul><sub id='Nt7dC'></sub></form><legend id='Nt7dC'></legend><bdo id='Nt7dC'><pre id='Nt7dC'><center id='Nt7dC'></center></pre></bdo></b><th id='Nt7dC'></th></span></q></dt></tr></i><div id='Nt7dC'><tfoot id='Nt7dC'></tfoot><dl id='Nt7dC'><fieldset id='Nt7dC'></fieldset></dl></div>

      从aspx网页读取xml

      时间:2023-06-02

      1. <i id='fcEpk'><tr id='fcEpk'><dt id='fcEpk'><q id='fcEpk'><span id='fcEpk'><b id='fcEpk'><form id='fcEpk'><ins id='fcEpk'></ins><ul id='fcEpk'></ul><sub id='fcEpk'></sub></form><legend id='fcEpk'></legend><bdo id='fcEpk'><pre id='fcEpk'><center id='fcEpk'></center></pre></bdo></b><th id='fcEpk'></th></span></q></dt></tr></i><div id='fcEpk'><tfoot id='fcEpk'></tfoot><dl id='fcEpk'><fieldset id='fcEpk'></fieldset></dl></div>
        1. <tfoot id='fcEpk'></tfoot>
            <bdo id='fcEpk'></bdo><ul id='fcEpk'></ul>
          • <legend id='fcEpk'><style id='fcEpk'><dir id='fcEpk'><q id='fcEpk'></q></dir></style></legend>

            <small id='fcEpk'></small><noframes id='fcEpk'>

                  <tbody id='fcEpk'></tbody>

                本文介绍了从aspx网页读取xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我们必须从一个 aspx 页面中读取数据.当我们使用查询字符串调用页面时,它会返回一个 xml 文档,其中包含与查询字符串匹配的数据.

                We have to read data from a aspx page. When we call the page with a query string, it returns an xml document with data that matches the query string.

                我们有一个与我们返回的 xml 匹配的 XSD.

                We have an XSD that matches the xml that we get back.

                我认为我们可以从 http 响应中读取 xml 文档.这行得通吗?

                I am thinking that we can read the xml document out of the http response. Will this work?

                我们如何绑定 XML 与 XSD,以便我们可以将 XML 文档视为强类型?

                How can we bind the XML with the XSD, such that we can treat the XML document as if it were strongly typed?

                谢谢,

                设拉子

                更新:

                找到这个关于如何反序列化的链接

                Found this link on how to deserialize

                在 C# 中将 XML 反序列化为对象

                推荐答案

                嗯,基本上,你可以请求一个类似这样的 XML 文档(这里没有 try/catch - 但你绝对应该添加它!):

                Well, basically, you can request an XML document something like this (no try/catch here - but you should definitely add that!):

                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 中,您不会有请求数据输出.

                Whether you have a GET or POST depends on your scenario - in a GET, you won't have request data going out.

                一旦您将 XML 作为 XmlDocument 恢复,您可以根据 XML 架构对其进行验证,或者只是尝试将其反序列化为您拥有的 XSD 架构所表示的类型.

                Once you have your XML back as a XmlDocument, you can either validate that against the XML schema, or just try to deserialize it into the type that is represented by the XSD schema you have.

                如果可行 --> 你得到的 XML 是有效的并且没问题.如果没有,您将在反序列化时遇到异常.

                If that works --> the XML you got is valid and OK. If not, you'll get an exception on deserialization.

                马克

                这篇关于从aspx网页读取xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:xsd.exe 将类生成为单独的文件? 下一篇:通过非制表符分隔符的非结构化 XML?

                相关文章

                最新文章

                <i id='RLbrq'><tr id='RLbrq'><dt id='RLbrq'><q id='RLbrq'><span id='RLbrq'><b id='RLbrq'><form id='RLbrq'><ins id='RLbrq'></ins><ul id='RLbrq'></ul><sub id='RLbrq'></sub></form><legend id='RLbrq'></legend><bdo id='RLbrq'><pre id='RLbrq'><center id='RLbrq'></center></pre></bdo></b><th id='RLbrq'></th></span></q></dt></tr></i><div id='RLbrq'><tfoot id='RLbrq'></tfoot><dl id='RLbrq'><fieldset id='RLbrq'></fieldset></dl></div>

                  <small id='RLbrq'></small><noframes id='RLbrq'>

                    <bdo id='RLbrq'></bdo><ul id='RLbrq'></ul>
                  <legend id='RLbrq'><style id='RLbrq'><dir id='RLbrq'><q id='RLbrq'></q></dir></style></legend>
                  1. <tfoot id='RLbrq'></tfoot>