c# - the type name text does not exist in the type xmlnodetype -
i trying read section xml file in c#. tried using code here compiler error under text
in xmlnodetype.text
weird thing comes intellisense , gives same error else element
,comment
etc.. missing?
xmltextreader reader = new xmltextreader(xmldoc); list<string> paths = new list<string>(); while (reader.read()) { if (reader.nodetype == xmlnodetype.element && reader.name == "paths") foreach(xmlnodetype.text aa in reader.readinnerxml()) paths.add(aa); } reader.close();
xml file
<config> <paths> <input>c:\</input> <output>c:\</output> <log>\logs</log> </paths> <systemownerroles> <supplier>supplier</supplier> <mop>mop</mop> </systemownerroles> </config>
xmlnodetype
enum. xmlnodetype.text
value, not type, you're trying use type of aa
variable. furthermore readerinnerxml()
returns string
, it's not clear how expect iterate on it.
do have use xmltextreader
this? xml work simpler using linq xml. example, think need:
var paths = xdocument.load(xmldoc) .descendants("paths") .elements() .select(element => (string) element) .tolist();
Comments
Post a Comment