Quiero leer el XML de LCO que publica el SAT en http://stackoverflow.com/questions/6705 ... o-read-xml usando la técnica de LINQ
El problema es que este XML trae el prefijo “lco” en cada nodo y no se como formar el XName para acensarlo.
Con un editor puedo quitarle el prefijo “lco” al XML y listo lo puedo leer con LINQ de hecho les anexo el código fuente de como hago el Query al LCO.xml y si funciona pero sin que traiga el prefijo … pero la idea no es estar quitando este prefijo “lco” , sino corregir el XName que se usa en la sentencia xdoc.Descendants("Certificado") y en la xdoc.Descendants("Contribuyente")
Mi pregunta es como acceso los nodos que traen el prefijo lco ( lco:Certificado y lco:Certificado ) usando LINQ ¿???
Saludos
Halcón Divino
Monterrey N.L.
México.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
String RutaLCO = @"C:\ProyectosWeb\DownLoadLCO\Datos\";
string xmlLCO = RutaLCO + "TestX.XML";
//Cargamos XML
XDocument xdoc = XDocument.Load(xmlLCO);
//Query
var LCO = from Contribuyente in xdoc.Descendants("Contribuyente")
select new
{
RFC = Contribuyente.Attribute("RFC").Value,
Certificados = Contribuyente.Descendants("Certificado")
};
//Resultado
foreach (var Contribuyente in LCO)
{
Console.WriteLine(Contribuyente.RFC);
foreach (var Certificado in Contribuyente.Certificados)
{
Console.WriteLine(" " + Certificado.Attribute("noCertificado").Value);
Console.WriteLine(" " + Certificado.Attribute("ValidezObligaciones").Value);
Console.WriteLine(" " + Certificado.Attribute("EstatusCertificado").Value);
Console.WriteLine(" " + Certificado.Attribute("FechaInicio").Value);
Console.WriteLine(" " + Certificado.Attribute("FechaFinal").Value);
}
}
}
}
}

DESCARGA SOFTWARE PARA FACTURA ELECTRONICA DE AQUI.
Facturacion, Validacion, Addendas, Librerias de programacion, etc.
CARTA PORTE V3.1
ECODEX TIENE ESTOS NUEVOS DATOS DE CONTACTO :
Comercializacion y Ventas - Evelia Vicke evicke@ecodex.com.mx 33-16-03-03-48
Soporte - Humberto Guerrero soporte@ecodex.com.mx 33-34-90-46-03
.
Leer LCO.XML con LINQ , me da problemas el prefijo lco
-
- Mensajes: 164
- Registrado: Vie Nov 25, 2011 3:12 pm
Leer LCO.XML con LINQ , me da problemas el prefijo lco
Saludos
Halcón Divino
Monterrey
Nuevo León
México
Halcón Divino
Monterrey
Nuevo León
México