Ok, I am fairly new to working with xml, xpath etc.
I am in the midst of writing a windows service that will pick up information from a queue. It will process this information and part of the processing of this information is using xpath on a xmldocument that I am creating than loading.
Code Snippet. :
XmlDocument _xmlDocument = new XmlDocument();
_xmlDocument.Load(svgFile);
_xmlNamespaceManager = new XmlNamespaceManager(_xmlDocument.NameTable);
_xmlNamespaceManager.AddNamespace("svg", "http://www.w3.org/2000/svg");
After the above snippet I am then doing some xpath functionality, I need to use this as there are some pre-written functions that will save me a large amount of time.
Here is the real issue, when I am using the AddNamespace above it is going out to that uri and taking up way too much time doing so (validating etc). My thought was if I could just download the DTD and create a local file that it would save that time that is being wasted going out to the web. Unfortunately, without AddNamespace xpath will not work.
I have researched this out on the web and haven’t been able to find a solution for this. The xml is created internally so I am not worried too much about having the most current schema from the web at this moment. I am more worried about generating the data from the service in a timely manner. Maybe I am completely wrong and this isn’t possible, but programmatically speaking I don’t see how this hasn’t been done before.
I ended up having to create my own xmlresolver class and then downloading the dtd and a bunch of mod files associated with it locally. Then rather than doing an xmldocument.load, you perform something like the below. :
Then your class is just something like this for your myXmlResolver class.
**Personal note can’t take all the credit as I took bits and pieces from a bunch of examples on the web.