如何使用C#从URL中读取XML节点?

如何使用C#从URL中读取XML节点?

问题描述:

我有类似下面的程序。这个概念是从读取URL XML值,但我的程序只读XML结构,而不是代码DATAS。像<计费地址>< /计费地址> ... 等而已。但原XML值<计费地址>&Strre1 LT; /计费地址> 。该计划不读取里面的值。

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 <Billing Address></Billing Address>... etc only. But the original XML value is <Billing Address>Strre1</Billing Address>. The Program does not read the inside value.

public static void zohoCRMReadAccounts()
{

    var val = auth();
    var val1= val[0];
    var val2= val[1];

    String xmlURL = "URL";
    XmlTextReader xmlReader = new XmlTextReader(xmlURL);
    while (xmlReader.Read())
    {
        switch (xmlReader.NodeType)
        {
            case XmlNodeType.Element: // The node is an element.
                Console.Write("<" + xmlReader.Name);
                // Read the attributes:
                while (xmlReader.MoveToNextAttribute()) 
                    Console.Write(" " + xmlReader.Name + "=’" 
                                   + xmlReader.Value + "’");
                Console.WriteLine(">");
                break;
            case XmlNodeType.Text: //Display the text in each element.
                Console.WriteLine(xmlReader.Value);
                break;
            case XmlNodeType.EndElement: //Display the end of the element.
                Console.Write("</" + xmlReader.Name);
                Console.WriteLine(">");
                break;
        }
    }
    Console.WriteLine("Press any key to continue…");
    Console.ReadLine(); //Pause
}

请帮我解决

XML元素不能有自己的名字空间。首先尝试

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