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

  • Home
  • SEARCH
  • 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 9114031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:06:33+00:00 2026-06-17T04:06:33+00:00

I am getting this error when I read an xml file with inline schema

  • 0

I am getting this error when I read an xml file with inline schema validation. The XML file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<SysConfig xmlns="PM-NameSpace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SysConfig.xsd">
...
</SysConfig>

The XSD file is in the same folder as the XML file and is called “SysConfig.xsd” and looks like this:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="PM-NameSpace" targetNamespace="PM-NameSpace">
...
</xs:schema>

I want to do inline schema validation in code, so my C# looks like this:

XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ValidationType = ValidationType.Schema;
xmlReaderSettings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
xmlReaderSettings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
xmlReaderSettings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
xmlReaderSettings.ValidationEventHandler += new ValidationEventHandler(handler);
XmlReader xmlReader = XmlReader.Create(sysConfigPath, xmlReaderSettings);
XmlDocument sysConfigXmlDocument = new XmlDocument();
sysConfigXmlDocument.Load(xmlReader);

As soon as Load is called (last line) the validation event handler is invoked, the actual message being:

Cannot load the schema for the namespace ‘ ‘ – The targetNamespace parameter ‘ ‘ should be the same value as the targetNamespace ‘PM-NameSpace’ of the schema.

which seems to indicate that something is using the default (”) namespace, but I have very carefully specified the xlmns and the target namespaces. I don’t understand what the error message means by “The targetNamespace parameter ‘ ‘ …” – the targetNamespace attribute is specified and is not blank (‘ ‘) – I don’t know what a “parameter” is in xml terms – or is it referring to something in (or missing from) the C# code?
Can anyone shed any light?

  • 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-17T04:06:34+00:00Added an answer on June 17, 2026 at 4:06 am

    I have not encountered this issue, but I believe the reason this is happening is that xsi:noNamespaceSchemaLocation is for actually indicating the XSD location for XML that has no namespace. Your XML actually has a namespace, so I believe you should replace that attribute with:

    xsi:schemaLocation="PM-NameSpace SysConfig.xsd"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When i read from the XML file, i read it like this and it
I have an xml file that looks like this: <!DOCTYPE ROOT SYSTEM zombie.dtd> <ROOT>
i am trying to read the xml file but somehow i am getting this
Hello I'm getting this error, while trying to save serial number to XML File.
On the query below I keep getting this error: Cannot read the next data
I've tried to read a big xml file (something like 500MB). First of all,
I am trying to read the XML Documentation file (C#) using this ocde -
I am getting a 401 unauthorized error when I try to read an XML
I am getting this error: io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence The
I'd like to read in an XML file that is stored on my Tomcat

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.