第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 XML 獲取數(shù)據:NetSuite WebService

從 XML 獲取數(shù)據:NetSuite WebService

C#
吃雞游戲 2023-07-22 18:09:42
我想從 獲取數(shù)據NetSuite WebService。這就是我的代碼的樣子:public class HomeController : Controller{    WebServiceGenesisSoapClient service;    public HomeController()    {        var aa = WebServiceGenesisSoapClient.EndpointConfiguration.WebServiceGenesisSoap;        service = new WebServiceGenesisSoapClient(aa);    }    public async Task<IActionResult> Index()    {        WebServiceGenesisSoapClient client = new WebServiceGenesisSoapClient(aa, "http://82.71.28.125/WebServiceGenesis/WebServiceGenesis.asmx");        GetStockQuantityArrayRequest getStockQuantityArrayRequest = new GetStockQuantityArrayRequest();        var stocklist = client.GetStockQuantityArrayAsync(getStockQuantityArrayRequest).Result;        ArrayOfXElement res = stocklist.GetStockQuantityArrayResult;    }}變量中存在兩個節(jié)點res。這是第一個節(jié)點的樣子:<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">    <xs:complexType>      <xs:choice minOccurs="0" maxOccurs="unbounded">        <xs:element name="StockQuantityArray">          <xs:complexType>            <xs:sequence>              <xs:element name="Colour" type="xs:string" minOccurs="0" />              <xs:element name="Quantity1" type="xs:int" minOccurs="0" />              <xs:element name="Quantity2" type="xs:int" minOccurs="0" />              <xs:element name="Quantity3" type="xs:int" minOccurs="0" />            </xs:sequence>          </xs:complexType>        </xs:element>      </xs:choice>    </xs:complexType>  </xs:element></xs:schema>這就是我的第二個節(jié)點的樣子:<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" />如果響應中存在數(shù)據,則它們存在于第二個節(jié)點中。如果數(shù)據不存在,我想獲取第一個節(jié)點元素name內的屬性值。xs:sequence
查看完整描述

2 回答

?
皈依舞

TA貢獻1851條經驗 獲得超3個贊

請嘗試這個


        XmlNode secondNode = getSecondNode();// read the second node from the res

        if (secondNode != null)

        {

            XmlNodeList xnList = secondNode.SelectNodes("//NewDataSet//Departments");

            foreach (XmlNode xn in xnList)

            {

                string code = xn.SelectSingleNode("Code") != null ? xn.SelectSingleNode("Code").Value : "";

                string Description = xn.SelectSingleNode("Description") != null ? xn.SelectSingleNode("Description").Value : "";

            }

        }

        else

        {


            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("bk", "http://www.w3.org/2001/XMLSchema");

            XmlNode firstNode = getFirstNode();// read the first node from the res

            XmlNodeList xnList = firstNode.SelectNodes("//bk:sequence//bk:element", nsmgr);

            foreach (XmlNode xn in xnList)

            {

                string value = ((System.Xml.XmlElement)xn).Attributes["name"].Value;

            }

        }


查看完整回答
反對 回復 2023-07-22
?
紅顏莎娜

TA貢獻1842條經驗 獲得超13個贊

嘗試以下 xml linq :


using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Xml;

using System.Xml.Linq;


namespace ConsoleApplication122

{

    class Program

    {

        const string FILENAME = @"c:\temp\test.xml";

        static void Main(string[] args)

        {

            XDocument doc = XDocument.Load(FILENAME);

            XElement root = doc.Root;

            XNamespace ns = root.GetDefaultNamespace();

            XNamespace nsDiffgr = root.GetNamespaceOfPrefix("diffgr");

            XNamespace nsData = root.GetNamespaceOfPrefix("msdata");


            List<Department> deparments = doc.Descendants(ns + "Departments").Select(x => new Department()

            {

                id = (string)x.Attribute(nsDiffgr + "id"),

                code = (string)x.Element(ns + "Code"),

                description = (string)x.Element(ns + "Description"),

                rowOrder = (int)x.Attribute(nsData + "rowOrder")

            }).ToList();


            Dictionary<string, Department> dict = deparments

                .GroupBy(x => x.id, y => y)

                .ToDictionary(x => x.Key, y => y.FirstOrDefault());

        }

    }

    public class Department

    {

        public string id { get; set; }

        public string code { get; set; }

        public string description { get; set; }

        public int rowOrder { get;set;}

    }


}


查看完整回答
反對 回復 2023-07-22
  • 2 回答
  • 0 關注
  • 169 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號