Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows Mobile 5读取XML时出错_C#_Xml_Web Services_Rest_Windows Mobile 5.0 - Fatal编程技术网

C# Windows Mobile 5读取XML时出错

C# Windows Mobile 5读取XML时出错,c#,xml,web-services,rest,windows-mobile-5.0,C#,Xml,Web Services,Rest,Windows Mobile 5.0,我很难得到这些值​​使用以下XML <ArrayOf xmlns="http://schemas.datacontract.org/2004/07/WcfServicePedido_v7" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <V> <D>S</D> <I>Z</I> <V>1</V> </V

我很难得到这些值​​使用以下XML

<ArrayOf    
   xmlns="http://schemas.datacontract.org/2004/07/WcfServicePedido_v7"
   xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<V>    
<D>S</D> 
<I>Z</I> 
<V>1</V> </V> <V>    
<D>S</D>    
<I>Z</I> 
<V>2</V> </V>    
</ArrayOf>

s
Z
1.
s
Z
2.
我曾经读过以下代码:

XmlReader xmlReader = XmlReader.Create(url);

XDocument x = XDocument.Load(xmlReader);

var EmpData = from emp in x.Descendants("V")
              select new M
              {
                  V = Convert.ToInt32(emp.Descendants("V").First().Value),
                  I = emp.Descendants("I").First().Value,
                  D = emp.Descendants("D").First().Value
              };

List<M> aux = EmpData.ToList();
XmlReader=XmlReader.Create(url);
XDocument x=XDocument.Load(xmlReader);
var EmpData=来自x.V中的emp(“V”)
选择新M
{
V=Convert.ToInt32(emp.substands(“V”).First().Value),
I=emp.substands(“I”).First()值,
D=emp.substands(“D”).First()值
};
List aux=EmpData.ToList();

我无法获得值​​. Empdata为空。

您的XML具有默认名称空间

// untested, from memory
XDocument x = XDocument.Load(xmlReader);
var ns = x.Root.GetDefaultnamespace();

var EmpData = from emp in x.Descendants(ns + "V")
              select new M
              ...
                Descendants(ns + "I")  

也许你想发布一个可编译的、有效的答案。不,我不想这样做。好吧,那只是一个评论。我会保留我的否决票。“只是一句评论”?你一定是在开玩笑。