Convert Hashtable to xml string and back to HashTable without using .NET Serializer

前端 未结 2 1056
死守一世寂寞
死守一世寂寞 2021-02-10 11:17

Does anyone know how to convert a Hashtable to an XML String then back to a HashTable without using the .NET based XMLSerializer. The XMLSerializer poses some security concerns

2条回答
  •  野的像风
    2021-02-10 11:53

    I don't have time to test this, but try:

    XDocument doc = new XDocument("HashTable",
                                   from de in hashTable
                                   select new XElement("Item",
                                                       new XAttribute("key", de.Key),
                                                       new XAttribute("value", de.Value)));
    

提交回复
热议问题