0

I'm having trouble getting the values ​​of the following 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>

I used to read the following code:

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();

I can not get the values​​. The Empdata is empty.

H H
  • 263,252
  • 30
  • 330
  • 514
user6018
  • 125
  • 6

1 Answers1

0

Your XML has a default namespace.

// 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")  
H H
  • 263,252
  • 30
  • 330
  • 514