小编Dav*_*uge的帖子

使用LINQ to XML将HTML标记保存在XML中

我有一个xml文件,我使用LINQ to XML从中提取html.这是该文件的示例:

<?xml version="1.0" encoding="utf-8" ?>
<tips>
    <tip id="0">
    This is the first tip.
</tip>
<tip id="1">
    Use <b>Windows Live Writer</b> or <b>Microsoft Word 2007</b> to create and publish content.
</tip>
<tip id="2">
    Enter a <b>url</b> into the box to automatically screenshot and index useful webpages.
</tip>
<tip id="3">
    Invite your <b>colleagues</b> to the site by entering their email addresses.  You can then share the content with them!
</tip>
</tips>
Run Code Online (Sandbox Code Playgroud)

我使用以下查询从文件中提取"提示":

Tip tip = (from t in tipsXml.Descendants("tip")
                   where …
Run Code Online (Sandbox Code Playgroud)

xml linq linq-to-xml

5
推荐指数
1
解决办法
2842
查看次数

标签 统计

linq ×1

linq-to-xml ×1

xml ×1