开发者

XmlTextReader and embedded resource DTD

开发者 https://www.devze.com 2023-02-28 04:33 出处:网络
I\'m trying to create a single EXE with no dependencies (spare the .NET Framework :-). The p开发者_JAVA技巧rogram involves parsing a bunch of XML docs (using XmlTextReader) that share the same DTD. Th

I'm trying to create a single EXE with no dependencies (spare the .NET Framework :-). The p开发者_JAVA技巧rogram involves parsing a bunch of XML docs (using XmlTextReader) that share the same DTD. The DTD is referred to by its name alone in the doc, so till now I've had it as "Copy if Newer" so it's in the same folder as the EXE itself.

Now I'd like to embed this DTD as an embedded resource in my project. I assume I'll need a custom XmlResolver to make my XmlTextReader happy, but I wasn't sure what that looked like. What's the secret sauce?


There is no secret sauce. Just Google for "XmlResolver", and you'll find the "System.Xml.XmlResolver class" article. At the bottom, you'll find a link to "Customizing the XmlUrlResolver class".

Use an instance of your custom resolver as the XmlResolver property of the XmlReaderSettings instance that you use in your XmlReader.Create call.

0

精彩评论

暂无评论...
验证码 换一张
取 消