asp.net - How can I load a hashtable from an XML file? -
I want to load all the names / values from a CSS file in the hashtable.
Note, the 'Value' section can contain HTML markup, so it will have to somehow save it in this code or should I use CDATA ?
Example XML:
& lt; Root & gt; & Lt; Node name = "node 1" & gt; Value & lt; / Node & gt; & Lt; Node name = "node 1" & gt; Value 2 & lt; / Node & gt; & Lt; Root & gt;Yes, I will wrap any HTML in CDATA, then to select it This will be trivialized in a
dictionary & lt; String, string & gt;.string xml = "& lt ;? Xml version = '1.0'? & Gt; root & gt; & lt; node name = \" node 1 \ "& gt; Value & lt; / node & gt; & lt; node name = \ "node2 \" & gt; value2 & lt; / node & gt; & lt; / root & gt; "; Var doc = XDocument.Parse (xml); Var dict = doc.Element ("root"). Elements ("node"). Select (E = & gt; new {key = e.Attribute ("name"). Value, value = e.value}). K = & gt; KK, V = & gt; V.Value);
Comments
Post a Comment