Get path from XML File using C# -
i'm needing path c:\sourcefiles\ xml file using c#.
i have been trying different escapes methods, nothing seems work correctly.
i have tried these:
@"c:\sourcefiles\ or c:\\sourcefiles\\ or "c:\\sourcefiles\\" , 'c:\sourcefiles'
none of these seem work when reading xml file.
xmldocument xdoc = new xmldocument(); xdoc.load(strpath); string strsourcedirectory = xdoc.selectsinglenode("application/setup/sourcedirectory").innertext;
here xml file:
<application> <setup> <sourcedirectory>"c:\sourcefiles\"</sourcedirectory> <destinationdirectory>@"c:\destinationfiles\"</destinationdirectory> </setup>
if has done c# , xml file, please let me know how did it.
thanks,
your xml file invalid. need escape backslash \\
, close application
tag:
<application> <setup> <sourcedirectory>c:\\sourcefiles\\</sourcedirectory> <destinationdirectory>c:\\destinationfiles\\</destinationdirectory> </setup> </application>
with valid xml, able path using code:
string strsourcedirectory = xdoc.selectsinglenode("application/setup/sourcedirectory").innertext;
Comments
Post a Comment