How to read XML node from URL using C#?

前端 未结 2 1483
小蘑菇
小蘑菇 2021-01-26 10:45

I\'m having program like below. The concept is Read XML value from URL, but my program read the xml structure only, not the code datas. Like

相关标签:
2条回答
  • 2021-01-26 10:49

    XML Elements cannot have spaces in their names. Try to remove them first

    0 讨论(0)
  • 2021-01-26 11:03

    First download the XML. Then Use like,

      try { 
        //read xml
        XmlDocument xdoc = new XmlDocument();
        xdoc.Load("XMLFilePath");
        XmlNodeList nodes = xdoc.SelectNodes(@"rss/channel/item");
        foreach (XmlNode node in nodes)
        {
          XmlNode titleNode = node.SelectSingleNode("title");
          string title = titleNode == null ? string.Empty : titleNode.InnerText;
    
          };
    

    }

    0 讨论(0)
提交回复
热议问题