我有一个 XmlDocument,其中有分层数据,我想将此数据导出到 Excel。请帮助我摆脱困境。我试图将这些数据读入数据集,但它不适合我。
问问题
1024 次
2 回答
0
请发送 xml 示例以获取更多信息。
您的代码将 xml 加载到数据集中,因此,如果您的 xml 没有从 DataSet 导出,您可以使用 LinqToXml。例如:
xml:
<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0">
<channel>
<title>Business Logic Toolkit for .NET</title>
<link>http://www.bltoolkit.net</link>
<description />
<lastBuildDate>2009-01-11</lastBuildDate>
<item>
<title>Version 3.1 released</title>
<link>http://www.bltoolkit.net/Download.htm</link>
<description>See <a href="http://www.bltoolkit.net/Download.htm">change log</a></description>
<pubDate>2009-01-11</pubDate>
</item>
<item>
<title>Version 3.0 released</title>
<link>http://www.bltoolkit.net/Download.htm</link>
<description>See <a href="http://www.bltoolkit.net/Download.htm">change log</a></description>
<pubDate>2008-05-21</pubDate>
</item>
<item>
<title>New examples</title>
<link>http://www.bltoolkit.net/Doc/</link>
<description>See the following <a href="http://www.bltoolkit.net/Doc/">link</a></description>
<pubDate>2008-05-10</pubDate>
</item>
</channel>
</rss>
此代码获取所有 RSS 项目的标题
var path = @"D:\rss.xml";
var doc = XDocument.Load(path);
rssTitles = doc.Root.Descendants("item").Elements("title").Select(el => el.Value);
结果:
Version 3.1 released
Version 3.0 released
New examples
于 2012-05-25T05:54:48.600 回答
0
<Roles>
<BalanceSheets RoleURL="http://fluor.com/role/BalanceSheets" RoleDefination="0020 - CONDENSED CONSOLIDATED BALANCE SHEET">
<Taxonomys>
<StatementOfFinancialPositionAbstract TaxonomyPresentationId="StatementOfFinancialPositionAbstract">
<StatementLineItems TaxonomyPresentationId="StatementOfFinancialPositionAbstract">
<LiabilitiesAndStockholdersEquityAbstract TaxonomyPresentationId="StatementLineItems">
<CommitmentsAndContingencies TaxonomyPresentationId="LiabilitiesAndStockholdersEquityAbstract" />
<OtherLiabilitiesNoncurrent TaxonomyPresentationId="LiabilitiesAndStockholdersEquityAbstract" />
<NonRecourseProjectFinanceDebtNoncurrent TaxonomyPresentationId="LiabilitiesAndStockholdersEquityAbstract" />
<LongTermDebtNoncurrent TaxonomyPresentationId="LiabilitiesAndStockholdersEquityAbstract" />
<LiabilitiesCurrentAbstract TaxonomyPresentationId="LiabilitiesAndStockholdersEquityAbstract">
<BillingsInExcessOfCost TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<LiabilitiesCurrent TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<AccountsPayable TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<BridgeLoan TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<NonRecourseProjectFinanceDebtCurrent TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<EmployeeRelatedLiabilities TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<OtherAccruedLiabilities TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
<ConvertibleDebtCurrent TaxonomyPresentationId="LiabilitiesCurrentAbstract" />
</LiabilitiesCurrentAbstract>
</LiabilitiesAndStockholdersEquityAbstract>
</StatementLineItems>
</StatementOfFinancialPositionAbstract>
</Taxonomys>
</BalanceSheets>
</Roles>
于 2012-05-25T06:48:01.177 回答