标题属性 [英] header attributes
问题描述
大家好,
我正在尝试从xml文件中提取所有属性。
我可以使用c#或vb #code也用于属性头属性?
我想要的是以下属性:
TransactionTypeCode =" 1" ServicerNumber = QUOT; xxxx187" ServicerLoanNumber = QUOT; xxx32" ProcessingStatusCode等
这是XML文件。
<?xml version =" 1.0"编码= QUOT; UTF-8英寸?>
- < MYResponseFile xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"的xmlns:XSD = QUOT; HTTP://www.w3.org/2001/XMLSchema" SchemaVersion = QUOT; 2.0" ProcessingDate = QUOT; 2011-11-14" FileProcessingStatusCode = QUOT; 0" FileProcessingMessageText ="已处理了包含153笔贷款的文件。有33个贷款有错误.135个贷款有警告。" NumberOfRecords = QUOT; 153"的xmlns = QUOT; HTTPS://www.MYadmin.com/schemas">
- < MYResponse TransactionTypeCode =" 1" ServicerNumber = QUOT; xxxx187" ServicerLoanNumber = QUOT; xxx32" ProcessingStatusCode = QUOT 1 QUOT;>
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-124] - 步骤校长。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-128] - 修改后的步骤付款到期日期+ 60个月。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-129] - 对最后一步的新兴趣。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-130] - 差异等于12个月。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-137] - 步进率p Schedule。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-141] - 上一个时间表的步骤付款日期。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-143] - 步骤PrinciPrincipal和利息支付。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-148] - 差异1%。" />
< MYErrorDetail AttributeName =" PostModificationDetail.AmortizationTerm"的AttributeValue = QUOT; 480" ErrorMessage ="警告:[LIR-152] - Amortizationll步骤加上th期间。" />
< MYErrorDetail AttributeName =" PostModificationDetail.ProductTypeCode"的AttributeValue = QUOT; 3英寸ErrorMessage ="警告:[LIR-170] - 步骤持续时间是初始时段。" />
< MYErrorDetail AttributeName =" PrincipalForgivenAmount"的AttributeValue = QUOT; 0.00" ErrorMessage ="错误:[LIR-358] - ‘ Principal Write-down(宽恕)’如果‘ Principal Reduction Alternative r‘ 3’。" />
< / MYResponse>
< / MYResponseFile>
谢谢
shamen
下面是使用LINQ to XML的C#中的示例(在.NET 3.5和4.0中可用):
XDocument doc = XDocumnent.Load(" file.xml");
XNamespace df = doc.Root.Name.Namespace;
XElement responseEl = doc.Root.Element(df +" MYResponse");
int code =(int)responseEl.Attribute(" TransactionTypeCode");
string serviceNumber =(string)responseEl.Attribute(" ServicerNumber");
string servicerLoanNumber =(string)responseEl.Attribute(" ServicerLoanNumber");
int procCode =(int)responseEl.Attribute(" ProcessingStatusCode");
Hi All,
I am trying to extrac all the attributes from a xml file.
Can i use c# or vb# code to attribute the header attributes too?
What I want are the following attributes:
TransactionTypeCode="1" ServicerNumber="xxxx187" ServicerLoanNumber="xxx32" ProcessingStatusCode etc
This is the XML file.
<?xml version="1.0" encoding="utf-8" ?> - <MYResponseFile xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SchemaVersion="2.0" ProcessingDate="2011-11-14" FileProcessingStatusCode="0" FileProcessingMessageText="The file with 153 loan(s) has been processed. There were 33 loan(s) with errors.135 loan(s) had warnings." NumberOfRecords="153" xmlns="https://www.MYadmin.com/schemas"> - <MYResponse TransactionTypeCode="1" ServicerNumber="xxxx187" ServicerLoanNumber="xxx32" ProcessingStatusCode="1"> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-124] - Step Principal ." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-128] - Step Payment Due Date after modification + 60 months." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-129] - New Interest to the last step." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-130] - Difference ust be equal to 12 months." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-137] - Step Rate p Schedule." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-141] - Step Paymentfective date of the previous schedule." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-143] - Step PrinciPrincipal and Interest Payment of ." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-148] - The differenan 1%." /> <MYErrorDetail AttributeName="PostModificationDetail.AmortizationTerm" AttributeValue="480" ErrorMessage="Warning:[LIR-152] - Amortizationll steps plus the th period." /> <MYErrorDetail AttributeName="PostModificationDetail.ProductTypeCode" AttributeValue="3" ErrorMessage="Warning:[LIR-170] - Step Durationnus the initial period." /> <MYErrorDetail AttributeName="PrincipalForgivenAmount" AttributeValue="0.00" ErrorMessage="Error:[LIR-358] - The‘Principal Write-down (Forgiveness)’ if the ‘Principal Reduction Alternative r ‘3’." /> </MYResponse> </MYResponseFile>
Thanks
shamen
Here is an example in C# using LINQ to XML (available in .NET 3.5 and 4.0):
XDocument doc = XDocumnent.Load("file.xml");
XNamespace df = doc.Root.Name.Namespace;
XElement responseEl = doc.Root.Element(df + "MYResponse");
int code = (int)responseEl.Attribute("TransactionTypeCode");
string serviceNumber = (string)responseEl.Attribute("ServicerNumber");
string servicerLoanNumber = (string)responseEl.Attribute("ServicerLoanNumber");
int procCode = (int)responseEl.Attribute("ProcessingStatusCode");
这篇关于标题属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!