私のXML:
<?xml version="1.0" encoding="utf-8"?>
<Horizon-Export>
<BatchNo.>1</BatchNo.>
<SpecimenID>CL1</SpecimenID>
<OperatorName>Anuj</OperatorName>
<SpecimenAge>1.00</SpecimenAge>
<Grade>M12</Grade>
<DateofCasting>01/09/2012</DateofCasting>
<SpecimenShape>Cube</SpecimenShape>
<SpecimenSize>150.00</SpecimenSize>
<Area>22,500</Area>
<Weight>10.0</Weight>
<Density>1.00</Density>
<TestDate>17/09/2012</TestDate>
<TestTime>9:41:08 AM</TestTime>
<BatchDate>17/09/2012</BatchDate>
<UltimateForce>
</UltimateForce>
<UltimateStress>
</UltimateStress>
<Remarks>Pass</Remarks>
<BatchNo.>1</BatchNo.>
<SpecimenID>CL1</SpecimenID>
<OperatorName>Anuj</OperatorName>
<SpecimenAge>1.00</SpecimenAge>
<Grade>M12</Grade>
<DateofCasting>01/09/2012</DateofCasting>
<SpecimenShape>Cube</SpecimenShape>
<SpecimenSize>150.00</SpecimenSize>
<Area>22,500</Area>
<Weight>10.0</Weight>
<Density>1.00</Density>
<TestDate>17/09/2012</TestDate>
<TestTime>9:47:10 AM</TestTime>
<BatchDate>17/09/2012</BatchDate>
<UltimateForce>25.3</UltimateForce>
<UltimateStress>1.12</UltimateStress>
<Remarks>Pass</Remarks>
<BatchNo.>1</BatchNo.>
<SpecimenID>CL1</SpecimenID>
<OperatorName>Anuj</OperatorName>
<SpecimenAge>1.00</SpecimenAge>
<Grade>M12</Grade>
<DateofCasting>01/09/2012</DateofCasting>
<SpecimenShape>Cube</SpecimenShape>
<SpecimenSize>150.00</SpecimenSize>
<Area>22,500</Area>
<Weight>10.0</Weight>
<Density>1.00</Density>
<TestDate>17/09/2012</TestDate>
<TestTime>9:48:57 AM</TestTime>
<BatchDate>17/09/2012</BatchDate>
<UltimateForce>8.3</UltimateForce>
<UltimateStress>0.37</UltimateStress>
<Remarks>Pass</Remarks>
<BatchNo.>1</BatchNo.>
<SpecimenID>CL1</SpecimenID>
<OperatorName>Anuj</OperatorName>
<SpecimenAge>1.00</SpecimenAge>
<Grade>M12</Grade>
<DateofCasting>01/09/2012</DateofCasting>
<SpecimenShape>Cube</SpecimenShape>
<SpecimenSize>150.00</SpecimenSize>
<Area>22,500</Area>
<Weight>10.0</Weight>
<Density>1.00</Density>
<TestDate>17/09/2012</TestDate>
<TestTime>9:49:20 AM</TestTime>
<BatchDate>17/09/2012</BatchDate>
<UltimateForce>10.9</UltimateForce>
<UltimateStress>0.49</UltimateStress>
<Remarks>Pass</Remarks>
<BatchNo.>1</BatchNo.>
<SpecimenID>CL1</SpecimenID>
<OperatorName>Anuj</OperatorName>
<SpecimenAge>1.00</SpecimenAge>
<Grade>M12</Grade>
<DateofCasting>01/09/2012</DateofCasting>
<SpecimenShape>Cube</SpecimenShape>
<SpecimenSize>150.00</SpecimenSize>
<Area>22,500</Area>
<Weight>10.0</Weight>
<Density>1.00</Density>
<TestDate>17/09/2012</TestDate>
<TestTime>9:49:42 AM</TestTime>
<BatchDate>17/09/2012</BatchDate>
<UltimateForce>2.6</UltimateForce>
<UltimateStress>0.12</UltimateStress>
<Remarks>Pass</Remarks>
</Horizon-Export>
私の CS:
private List<CubeTestDTL> ParseXMLToList()
{
List<CubeTestDTL> cubeTestDetailList = new List<CubeTestDTL>();
if (fuImport.HasFile)
{
if (fuImport.PostedFile.ContentLength > 0)
{
var name = string.Format("{0}.xml", Guid.NewGuid().ToString().Replace("-", string.Empty));
var filePath = string.Format("~/Temp/{0}",name);
fuImport.SaveAs(Server.MapPath(filePath));
cubeTestDetailList =
(
from e in XDocument.Load(Server.MapPath(string.Format("~/Temp/{0}",name))).Root.Elements("Horizon-Export")
select new CubeTestDTL
{
Srlno = (int)e.Element("BatchNo."),
Accd = Session["ACCD"].ToString(),
AvgCompStrength = 0,
BreakingLoad = (double)e.Element("UltimateForce"),
CompStrength = (double)e.Element("UltimateStress"),
CubeArea = (double)e.Element("Area"),
CubeDensity = (double)e.Element("Density"),
CubeNo = (string)e.Element("SpecimenID"),
CubeWeight = (double)e.Element("Weight"),
CustDate = (DateTime)e.Element("DateofCasting"),
Grade = (string)e.Element("Grade"),
Location = (string)e.Element("OperatorName"),
MainAccd =Session["MAINACCD"].ToString(),
TargetStrength = 0,
TestOn = (double)e.Element("TestDate"),
}).ToList<CubeTestDTL>();
}
}
return cubeTestDetailList;
}
問題:
解析が0アイテムを返すたびに。linq ブロック全体が一度に通過するため、デバッグできません。List Count は常に =0 を示しています。