C#-WinForms中的XML到ListView

时间:2018-12-17 23:49:49

标签: xml listview

您可以帮助编写代码,以便在winformsl的列表视图中解析此类型的xml。您应该获得颜色的名称及其值。在这种情况下,请勿判断昂贵的新手。预先感谢您的建议。

<?xml version="1.0" encoding="utf-8"?>
        <resources>
          <color name="abc_input_method_navigation_guard">@android:color/black</color>
          <color name="abc_search_url_text_normal">#ff7fa87f</color>
          <color name="abc_search_url_text_pressed">@android:color/black</color>
          <color name="abc_search_url_text_selected">@android:color/black</color>
          <color name="accent_material_dark">@color/material_deep_teal_200</color>
          <color name="accent_material_light">@color/material_deep_teal_500</color>
          <color name="background_floating_material_dark">@color/material_grey_800</color>
          <color name="background_floating_material_light">@android:color/white</color>
          <color name="background_material_dark">@color/material_grey_850</color>
          <color name="background_material_light">@color/material_grey_50</color>
          <color name="bright_foreground_disabled_material_dark">#80ffffff</color>
          <color name="bright_foreground_disabled_material_light">#80000001</color>
    </resources>

1 个答案:

答案 0 :(得分:0)

PFB代码。它正在工作。

   XDocument xmlDoc = XDocument.Load("yourXMLFile.xml");
   var list = xmlDoc.Root.Elements("color")
                       .Select(element => element.Value)
                       .ToList();