Correct XSD to ignore embedded markup with namespaces

Long story short, I have the following XML contained in a file (not really, but this models what I am doing):

<myElement name="myElement1">
  <Template Culture="1033">
    <asp:Label ID="Label1" runat="server" Text="Hello World!" />
  </Template>
  <Template Culture="10">
    <asp:Label ID="Label1" runat="server" Text="Hola mundo!" />
  </Template>
</myElement>

I am trying to load the file into a System.Xml.XmlDocument instance so the contents can be parsed.  Unfortunately, .NET throws an exception because it says that "asp" is an unrecognized namespace.  (Btw, an XmlReader is not appropriate because I need bi-directional access to the data.)

My thought is to create an XML Schema definition that tells .NET to treat anything inside a <Template> element as raw text and not try to parse it - I will handle that myself.  So far I have been unable to do so.

I appreciate any help figuring out how to accomplish this.
SonOfPirateAsked:
Who is Participating?
 
Geert BormansInformation ArchitectCommented:
This is nothing you can solve with an XSD.
Schema validation needs to happen on a wellformed document.
So, the wellformedness check comes first and if you don't bind the prefix to a namespace,
this XML snippet is simply unwellformed (this means it is not XML)
You can easily tell the validating parser to not care about the content for a specific element,
if you make the content model xsd:any and validation lax.
I can show you how if you want to,
but this will not solve your problem

you will nee to change your XML like this
<myElement name="myElement1" xmlns:asp="some-uri-here>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.