Parsing xml (android files)



  • How can you evaporate on the C# is this xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <public type="attr" name="twSoftkeyItemStyle" id="0x7f010000" />
        <public type="attr" name="twSoftkeyItemType" id="0x7f010001" />
        <public type="attr" name="twSoftkeyItemText" id="0x7f010002" />
        <public type="attr" name="twSoftkeyItemImage" id="0x7f010003" />
    </resources>
    

    Spark needs all the "public" or the exact type name id. It is also interesting to know how to remove the public name line from the xml file and preserve it.



  • Simple. Put your XML in. XDocument (sighs)XDocument.Load or XDocument.ParseNext.

    doc.Descendants("public").Attributes("id").Select(a => a.Value)
    

    If you need numbers,

    doc.Descendants("public").Attributes("id").Select(a => Convert.ToInt32(a.Value, 16));
    

    To remove the knot on the attribute, for example:

    var attributesToDelete =
        doc.Descendants("public")
           .Attributes("name")
           .Where(a => a.Value == <здесь ваше значение>)
           .ToList();
    foreach (var attr in attributesToDelete)
        attr.Parent.Remove();
    

    Continuing new XDocument As usual, through Save




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2