我需要写一个异常表。因此,如果UploadStatus =“ Failed”,我需要从CDR_STATUS元素中获取ClientLoanNumber和UploadedDt,然后在CDR_ERROR元素中获取任何内容。因此,我认为CDR_STATUS有一个主循环,并在条件UploadStatus =“ Failed”下通过CDR_STATUS元素循环。我需要返回的是ClientLoanNumber,UploadedDt和来自CDR_Status元素的消息。
以下是提供者的实际回复。格式很糟糕。抱歉。我是c#开发人员,所以正在寻找c#。感谢您的帮助。
<?xml version="1.0" encoding="UTF-8"?>
<CWL_DATA>
<CWL_RESPONSE RequestType="CDRSearch" ClientID="11559" ResponseDateTime="6/26/2018 2:43:31 PM">
<CRITERIA ReferenceNumber="412497" DateFrom="6/26/2018" DateTo="" UploadFileName="" />
<RESPONSE_DATA>
<CDR_STATUS UploadStatus="Failed" CWLLoanNumber="10050764" ClientLoanNumber="7000904180" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Beeching" LoanAmt="146520.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
<CDR_ERROR Message="Loan Number and / or Date Time stamp is not valid. Please download the excel file again and re-import using the new excel file."/>
<CDR_ERROR Message="MFR Units is invalid."/>
<CDR_ERROR Message="Please enter MIP% as a decimal number between 0.001 and 100 with up to 3 decimal digits."/>
</CDR_STATUS> <CDR_STATUS UploadStatus="Failed" CWLLoanNumber="10050766" ClientLoanNumber="7000907217" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Ginsburg" LoanAmt="69000.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
<CDR_ERROR Message="Loan Number and / or Date Time stamp is not valid. Please download the excel file again and re-import using the new excel file."/>
<CDR_ERROR Message="MFR Units is invalid."/>
<CDR_ERROR Message="Base Loan Amount is not required for loans with Loan Type other than `FHA', 'CL FHA', 'VA' and 'CL VA'."/>
</CDR_STATUS> <CDR_STATUS UploadStatus="Failed" CWLLoanNumber="10050765" ClientLoanNumber="7000907225" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Cesaro" LoanAmt="83838.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
<CDR_ERROR Message="Loan Number and / or Date Time stamp is not valid. Please download the excel file again and re-import using the new excel file."/>
<CDR_ERROR Message="MFR Units is invalid."/>
<CDR_ERROR Message="Please enter MIP% as a decimal number between 0.001 and 100 with up to 3 decimal digits."/>
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050767" ClientLoanNumber="7000908314" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Massari" LoanAmt="191919.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050768" ClientLoanNumber="7000909833" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Varney" LoanAmt="76312.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050769" ClientLoanNumber="7000911722" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Lawson Cousins" LoanAmt="290000.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050770" ClientLoanNumber="7000911763" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Ball" LoanAmt="207570.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050771" ClientLoanNumber="7000914155" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Rauf" LoanAmt="404700.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> <CDR_STATUS UploadStatus="Pending" CWLLoanNumber="10050773" ClientLoanNumber="7000915947" FileName="WebService6/26/2018 2:43:25 PM" UploadedDt="6/26/2018 2:43:25 PM" BorrowerLastName="Dino" LoanAmt="245471.00" LineType="Repo" RequestType="Wire" LoanStatus="Suspended" >
</CDR_STATUS> </RESPONSE_DATA>
</CWL_RESPONSE>
</CWL_DATA>
答案 0 :(得分:1)
这就是我的工作。
DataTable resultsDT = new DataTable();
resultsDT.Columns.Add("LoanNUmber");
resultsDT.Columns.Add("Error");
XDocument X = XDocument.Load(pathStatusRequestResult);
var status = X.Element("CWL_DATA").Element("CWL_RESPONSE");
var statusData = status.Element("RESPONSE_DATA").Elements("CDR_STATUS");
foreach(var item in statusData)
{
// returns the value of teh UploadStatus
bool uploadStatus = (item.Attribute("UploadStatus").Value) == "Failed" ? false : true;
string loanNumber = item.Attribute("ClientLoanNumber").Value;
if (uploadStatus == false)
{
var errorData = item.Elements("CDR_ERROR");
foreach(var e in errorData)
{
string error = e.Attribute("Message").Value;
resultsDT.Rows.Add(loanNumber, error);
}
}
}
答案 1 :(得分:-1)
我将结果放入数据表:
stringi::stri_pad_left(trial, width = nb, pad = "0")