Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8734451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:50:37+00:00 2026-06-13T09:50:37+00:00

Ok, I am fairly new to working with xml, xpath etc. I am in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:50:38+00:00Added an answer on June 13, 2026 at 9:50 am

    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. :

                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.DTD;
                settings.ProhibitDtd = false;
                settings.XmlResolver = new MyCoolResolver();
                binDirectory = binDirectory + "/content";
                string myFileLocation = binDirectory + "/MyFile.svg";
    
                using (XmlReader reader = XmlReader.Create(myFileLocation , settings))
                {
                    try
                    {
                        while (reader.Read())
                        {
                            _xmlDocument.Load(reader);
                        }
                    }
                    catch (XmlException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
    

    Then your class is just something like this for your myXmlResolver class.

    namespace ReallyCoolProject
    {
        public class MyCoolResolver : XmlUrlResolver
        {
             public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
             {
                string binDirectory =               Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                binDirectory = binDirectory + "/mods";
    
                if (absoluteUri.OriginalString.Contains("-//W3C//DTD SVG 1.1//EN"))
                {
                    return File.Open(binDirectory + "/svg11.dtd", FileMode.Open);
                }
    
                if (absoluteUri.OriginalString.Contains("-//W3C//ENTITIES SVG 1.1 Document Model//EN"))
                {
                    return File.Open(binDirectory + "/svg11-model.mod", FileMode.Open);
            }
    
            //.....many many more mod files than this
    
         }
        }
    }
    

    **Personal note can’t take all the credit as I took bits and pieces from a bunch of examples on the web.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a fairly new project and we started from scratch. So not
I'm fairly new to Dreamweaver, I've been working on a website that contains a
I'm fairly new to using JSON (as opposed to XML) and am currently working
I'm fairly new to Python, and I've just started working with XML parsing. I
I am fairly new to Silverlight. I have an application I'm working on that
I am fairly new to java having come from a VS2010 background. Currently working
I'm fairly new to programming in general. I'm working on a simple app that
I'm fairly new to working with relational databases, but have read a few books
I am fairly new to ASP.NET MVC and working on a small project in
I am fairly new to programming and I am working with Objective C. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.