A small example of the c xml API operation

  • 2020-05-27 07:02:12
  • OfStack


LoginInfo loginInfo = new LoginInfo();
xmlNode = _xml.SelectSingleNode(loginUrl);
loginInfo.LoginUrl = xmlNode.InnerText;
xmlNode = _xml.SelectSingleNode(loginUser);
loginInfo.UserId = xmlNode.Attributes["tagId"].Value;
loginInfo.UserValue = xmlNode.InnerText;
xmlNode = _xml.SelectSingleNode(loginPwd);
loginInfo.PwdId = xmlNode.Attributes["tagId"].Value;
loginInfo.PwdValue = xmlNode.InnerText;
xmlNode = _xml.SelectSingleNode(loginBtnId);
loginInfo.BtnId = xmlNode.InnerText;    

XML:


 <login>
      <url>https://www.ofstack.com/JLxxxxn/Lxxxxx.aspx</url>
      <user tagId="txtAccount">xxxx</user>
      <pwd tagId="txtPassword">xxxxx</pwd>
      <btnId>btnLogin</btnId>
    </login>

Take the middle value of the node and use xmlNode.InnerText, that is, use the InnerText attribute. Such as < btnId > btnLogin < /btnId >

Take the value of the property using xmlNode.Attributes ["tagId"].Value, Value of the property, e.g < user tagId="txtAccount" > xxxx < /user > tagId belong to


Related articles: