Adding XML namespace reference in vb.net
I'm writing a piece of software that accepts XML from our clients.
The xml has2 parts, a standard part that contains set fields, and a freeform part that allows our clients to add own their own xml

    <OverallDocument>
        <SetFields>
            <name>Jon Doe</name>
            <age>24</age>
            <sex>M</sex>
        </SetFields>
        <FreeXML>
        <!--custom xml goes here-->
        </FreeXML>
    </OverallDocument>


The system is set so that the OverallDocument has a schema that covers all sections of the xml except what goes inside the FreeXML tags.
The contents of the FreeXML tags has it's own schema sent to us by our client. 

    <OverallDocument>
        <SetFields>
            <name>Jane Doe</name>
            <age>30</age>
            <sex>F</sex>
        </SetFields>
        <FreeXML>
        <Custom1>
            <CustomString>aaaaaa</CustomString>
            <CustomInt>12345</CustomInt>
        </Custom1>
        </FreeXML>
    </OverallDocument>

In this case the client's xml looks like this

    <Custom1>
        <CustomString>aaaaaa</CustomString>
        <CustomInt>12345</CustomInt>
    </Custom1>

The program is trying to extract the client's custom xml for further processing.

So far, no problems. this all reads nicely into an xmldocument.
Unfortunatly some of our clients use namespace prefixes on their custom xml without declaring the prefixes in the xml document.

    <OverallDocument>
        <SetFields>
            <name>Jane Doe</name>
            <age>30</age>
            <sex>F</sex>
        </SetFields>
        <FreeXML>
        <hl:Custom1>
            <CustomString>aaaaaa</CustomString>
            <CustomInt>12345</CustomInt>
        </hl:Custom1>
        </FreeXML>
    </OverallDocument>

This causes the xmldocument to fall over as the prefixes are not declared in the xml. I tried getting around this by removing all namespace prefixes from the code, but this causes issues later on in the processing as the clients' schemas require the prefixes to be on the tags.

some further problems

 - We have many clients with different
   schemas and different namespaces.
 - Each XML file can have multiple
   FreeXML elements in different
   sections (so it's not possible to
   simply extract the FreeXML section as
   different clients use 1 or more and
   use sections in different locations
   throughout the document.
 - We cannot edit the clients' schema.
 - We cannot tell the clients to sort
   their act out and write working xml.

Ideally it would be best if we can just specify the namespace and prefix to the xmldocument reader.
eg

    dim xdoc as xmldocument = xmldocument
    'add namespace and prefix
    xdoc.load(xmlcode)





Adding XML namespace reference in vb.net
===

I'm writing a piece of software that accepts XML from our clients.
The xml has2 parts, a standard part that contains set fields, and a freeform part that allows our clients to add own their own xml

    <OverallDocument>
        <SetFields>
            <name>Jon Doe</name>
            <age>24</age>
            <sex>M</sex>
        </SetFields>
        <FreeXML>
        <!--custom xml goes here-->
        </FreeXML>
    </OverallDocument>


The system is set so that the OverallDocument has a schema that covers all sections of the xml except what goes inside the FreeXML tags.
The contents of the FreeXML tags has it's own schema sent to us by our client. 

    <OverallDocument>
        <SetFields>
            <name>Jane Doe</name>
            <age>30</age>
            <sex>F</sex>
        </SetFields>
        <FreeXML>
        <Custom1>
            <CustomString>aaaaaa</CustomString>
            <CustomInt>12345</CustomInt>
        </Custom1>
        </FreeXML>
    </OverallDocument>

In this case the client's xml looks like this

    <Custom1>
        <CustomString>aaaaaa</CustomString>
        <CustomInt>12345</CustomInt>
    </Custom1>

The program is trying to extract the client's custom xml for further processing.

So far, no problems. this all reads nicely into an xmldocument.
Unfortunatly some of our clients use namespace prefixes on their custom xml without declaring the prefixes in the xml document.

    <OverallDocument>
        <SetFields>
            <name>Jane Doe</name>
            <age>30</age>
            <sex>F</sex>
        </SetFields>
        <FreeXML>
        <hl:Custom1>
            <CustomString>aaaaaa</CustomString>
            <CustomInt>12345</CustomInt>
        </hl:Custom1>
        </FreeXML>
    </OverallDocument>

This causes the xmldocument to fall over as the prefixes are not declared in the xml. I tried getting around this by removing all namespace prefixes from the code, but this causes issues later on in the processing as the clients' schemas require the prefixes to be on the tags.

some further problems

 - We have many clients with different
   schemas and different namespaces.
 - Each XML file can have multiple
   FreeXML elements in different
   sections (so it's not possible to
   simply extract the FreeXML section as
   different clients use 1 or more and
   use sections in different locations
   throughout the document.
 - We cannot edit the clients' schema.
 - We cannot tell the clients to sort
   their act out and write working xml.

Ideally it would be best if we can just specify the namespace and prefix to the xmldocument reader.
eg

    dim xdoc as xmldocument = xmldocument
    'add namespace and prefix
    xdoc.load(xmlcode)




