【问题标题】:Pass a string in C#在 C# 中传递一个字符串
【发布时间】:2021-02-07 08:08:43
【问题描述】:

我试图通过 C# 代码传递此字符串但失败:

soap:Body1479374

System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); doc.LoadXml(string);

尝试发送整体和 3 个部分,但在 Sectiona 内失败

string Sectiona = @"soap:Body";

字符串 Sectionb = "1479374";

string Sectionc = "";

字符串数据 = Sectiona + Sectionb + Sectionc;

【问题讨论】:

    标签: c# xml string web-services


    【解决方案1】:

    你的肥皂身体标签是错误的。使用 xml linq:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml;
    using System.Xml.Linq;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string xml = "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body>1479374</soap:Body></soap:Envelope>";
                XDocument doc = XDocument.Parse(xml);
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-06
      • 2016-06-17
      • 2012-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多