How to process webdav server XML request in C# -
How to process webdav server XML request in C# -
i writing custom webdav server in c#. 1 of client test programs using netdrive , claims , appears webdav compliant client. problem receiving request on server in next format:
<?xml version="1.0" encoding="utf-8"?> <propfind xmlns="dav:"> <allprop/> </propfind>
but other clients this:
<?xml version="1.0" encoding="utf-8"?> <d:propfind xmlns:d="dav:"> <d:allprop/> </d:propfind>
the 2 different namespace formats maintain on fooing logic "allprop" element. code looks bit this:
string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><propfind xmlns=\"dav:\"><allprop/></propfind>"; //hardcode create stackoverflow users' lives easier xpathdocument doc = new xpathdocument(new stringreader(xml)); xpathnavigator nav = doc.createnavigator(); xpathnodeiterator = nav.select("/propfind/*");
now, know need set in type of namespace manager "dav:", tried this:
xmlnamespacemanager nsman = new xmlnamespacemanager(nav.nametable); nsman.addnamespace("", "dav"); xpathnodeiterator = nav.select("/propfind/*", nsman);
but i'm getting no nodes in iterator first xml file. seems default namespace isn't working thought should.
what doing wrong? how query xml existence of allprop
node when namespace may default, or may explicitly named?
you using wrong namespace in code. unforunalely webdav specs utilize 'dav:' namespace webdav nodes , attributes (this seems caused missunderstanding of xml namespace mechanism).
c# xml xml-namespaces webdav
Comments
Post a Comment