I have this XML file
<?xml version="1.0" encoding="us-ascii" ?>
<LoanSetupFile SchemaVersion="3.0" NumberOfLoans="2" xmlns="http://ift.tt/1qqRTNn">
<Loan ServicerLoanNumber="1"/>
<Loan ServicerLoanNumber="2"/>
</LoanSetupFile>
I'm trying to get the ServicerLoanNumber attribute. I've tried a lot of ways, and this might be my closest attempt, but still it's returning null
var doc = XDocument.Load("fileName.xml");
XNamespace ns = doc.Root.GetDefaultNamespace(); //This gives me the correct namespace
var loans = from l in doc.Descendants(ns+"Loan") select new { ServicerLoanNumber = l.Attribute("ServicerLoanNumber").Value };
Does anyone know what's wrong with this? Do I need to include the SchemaVersion? If so, how?
Thanks a lot..
No comments:
Post a Comment