我有一个XML,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<MIFORMS_EXPORT>
<SESSION FORM_ID="775938" CID="" ID="HAKKI-LAPTOP_634975758376381105">
<FIELD NAME="A001DATE_M" Y="2.32" X="5.5" WIDTH="7.15" HEIGHT="0.99" />
<FIELD NAME="A002" Y="2.32" X="17.83" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="A003" Y="1.11" X="17.83" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="A004" Y="1.11" X="5.5" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="OR01" Y="7.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR02" Y="8.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR03" Y="9.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR04" Y="10.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR05" Y="11.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR06" Y="12.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR07" Y="13.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR08" Y="14.02" X="17" WIDTH="2.21" HEIGHT="0.6" />
<FIELD NAME="OR99" Y="16.52" X="17.5" WIDTH="1.59" HEIGHT="0.99" />
<FIELD NAME="DESCRIPTOR" Y="25" X="17.5" WIDTH="2" HEIGHT="0.5" />
<FIELD NAME="A001DATE_M_2" Y="2.32" X="5.5" WIDTH="7.15" HEIGHT="0.99" />
<FIELD NAME="A002_2" Y="2.32" X="17.83" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="A003_2" Y="1.11" X="17.83" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="A004_2" Y="1.11" X="5.5" WIDTH="2.38" HEIGHT="0.99" />
<FIELD NAME="WTA101" Y="8" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA102" Y="8.7" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA103" Y="9.42" X="5.01" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA104" Y="10.12" X="5.01" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA105" Y="10.82" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA106" Y="11.51" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA107" Y="12.21" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA108" Y="12.91" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA109" Y="13.63" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA110" Y="14.35" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA111" Y="15.07" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA112" Y="15.77" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA113" Y="16.47" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA114" Y="17.18" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA115" Y="17.93" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA116" Y="18.65" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA117" Y="19.38" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA118" Y="20.08" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA119" Y="20.79" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA120" Y="21.5" X="5.01" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA121" Y="22.21" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA122" Y="22.96" X="5.01" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA123" Y="23.66" X="5.01" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA124" Y="24.38" X="5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA201" Y="8.01" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA202" Y="8.71" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA203" Y="9.42" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA204" Y="10.12" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA205" Y="10.82" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA206" Y="11.51" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA207" Y="12.21" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA208" Y="12.91" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA209" Y="13.63" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA210" Y="14.35" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA211" Y="15.07" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA212" Y="15.77" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA213" Y="16.47" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA214" TIMESTAMP="02/27/2013 15:30:43" Y="17.18" X="11.5" WIDTH="2.22" HEIGHT="0.6">1</FIELD>
<FIELD NAME="WTA215" Y="17.93" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA216" Y="18.65" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA217" Y="19.38" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA218" Y="20.08" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA219" Y="20.8" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA220" Y="21.5" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA221" Y="22.21" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA222" Y="22.97" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA223" Y="23.67" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA224" Y="24.38" X="11.5" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA301" Y="8.01" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA302" Y="8.71" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA303" Y="9.42" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA304" Y="10.12" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA305" Y="10.82" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA306" Y="11.51" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA307" Y="12.21" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA308" Y="12.91" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA309" Y="13.63" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA310" Y="14.35" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA311" Y="15.07" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA312" Y="15.77" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA313" Y="16.47" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA314" Y="17.18" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA315" Y="17.93" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA316" Y="18.65" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA317" Y="19.38" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA318" Y="20.08" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA319" Y="20.8" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA320" Y="21.5" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA321" Y="22.21" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA322" Y="22.97" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA323" Y="23.67" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA324" Y="24.38" X="18" WIDTH="2.22" HEIGHT="0.6" />
<FIELD NAME="WTA996" Y="25.8" X="3.21" WIDTH="1.59" HEIGHT="0.99" />
<FIELD NAME="WTA997" Y="25.81" X="8.2" WIDTH="1.59" HEIGHT="0.99" />
<FIELD NAME="WTA999" Y="25.81" X="18.19" WIDTH="1.59" HEIGHT="0.99" />
<FIELD NAME="WTA998" Y="25.81" X="13.2" WIDTH="1.59" HEIGHT="0.99" />
<IMAGE NAME="NewImagemap" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">775938-0-02272013-153112426-HAKKI-LAPTOP_634975758376381105.png</IMAGE>
<IMAGE NAME="NewImagemap" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">775938-1-02272013-153112504-HAKKI-LAPTOP_634975758376381105.png</IMAGE>
<IMAGE NAME="NewImagemap" TYPE="PAGE" FORMAT="image/png" RESOLUTION="28.35" DEPTH="24">775938-2-02272013-153112582-HAKKI-LAPTOP_634975758376381105.png</IMAGE>
</SESSION>
</MIFORMS_EXPORT>
我想遍历FIELD元素和值以及IMAGE Name和Resolution。
我正在使用C#并设计了这段代码:
var doc = XDocument.Parse(ea.Result);
var list = from p in doc.Descendants("FIELD")
select new ExportData
{
Height = (string) p.Attribute("HEIGHT"),
Width = (string) p.Attribute("WIDTH"),
X = (string) p.Attribute("X"),
Y = (string) p.Attribute("Y"),
ID = (string) p.Attribute("NAME"),
Value = p.Value,
Image = (from c in doc.Descendants("IMAGE") select c.Value).FirstOrDefault(),
Resolution = (from c in doc.Descendants("IMAGE") select c.Attribute("RESOLUTION").Value).FirstOrDefault()
};
var enumerable = list as ExportData[] ?? list.ToArray();
foreach (var data in enumerable)
{
//output
}
这使得FIELD工作正常,我从那里获得了所需的所有信息。但是对于IMAGE来说,同样的c.Value反复出现。
如何在循环浏览IMAGE.Value的同时循环使用FIELD?
感谢任何想法。