xmlns="" problem

XMLnovice

New member
Joined
Apr 24, 2006
Messages
2
Hello there I am new to XML and I am having a problem with xmlns="" showing up in my elements when I trying to produce a report in XML from VB6.
Code Example
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<MESSAGE xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tempuri.org/XMLSchema.xsd C:\projects\report\EDU-KIT\Docs\report_osad_edu.xsd">
The header part of this produced using a method called Load Header
Code:
 Set pi = oXMLDoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""ISO-8859-1""")
 Set eMessage = oXMLDoc.createElement("MESSAGE")
      oXMLDoc.appendChild eMessage
 Set aXmlns = oXMLDoc.createAttribute("xmlns")
 eMessage.setAttribute "xmlns", "http://tempuri.org/XMLSchema.xsd"
Set aXmlns_Data = oXMLDoc.createAttribute("xmlns:msdata")
 eMessage.setAttribute "xmlns:msdata", "urn:schemas-microsoft-com:xml-msdata"
Set aXmlns_Xsi = oXMLDoc.createAttribute("xmlns:xsi")
eMessage.setAttribute "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"
Set xsiSchema = oXMLDoc.createAttribute("xsiSchema")
 eMessage.setAttribute "xsi:schemaLocation", "http://tempuri.org/XMLSchema.xsd C:\projects\report\EDU-KIT\Docs\report_osad_edu.xsd"
This part is fine but the following part where an element is produced on the report is giving me a problem:
Code:
<DETAILS xmlns="">
<FIRSTNAME>John</FIRSTNAME>
<SURNAME>Carpenter</SURNAME>
</DETAILS>

<POSTAL_ADDRESS xmlns="">
<ADDRESS1>12 EAST PARK</ADDRESS>
<ADDRESS2>NEW STREET</ADDRESS2>
</POSTAL_ADDRESS>
This part is produced in a method called loadDetails
Code:
Set eDetails = oXMLDoc.createElement("DETAILS")
        eMessage.appendChild eDetails
Set eFirstName = oXMLDoc.createElement("FIRSTNAME")
        eDetails.appendChild eSchoolName
Set eSurname = oXMLDoc.createElement("SURNAME")
        eDetails.appendChild eSchoolName
etc..

Also later on the report I am getting an output like
Code:
<FAMILY xmlns:dt="urn:schema-microsoft-com:datatypes" DT:dt="String">
How is this extra bit appearing in the FAMILY element and this is created in the same way as <POSTAL_ADDRESS>

Also other elements are producing output like
Code:
<SON>
<SON_FIRST_NAME dt:dt="String">Mark</SON_FIRST_NAME>.

I sureif I can understand where this extra bit of info comes from and how to get rid of it in one i should be able to do the same for the rest but at the moment I so totally confused where all this extra output in the ELEMENT NAMES are coming from.
Hopefully someone can help me.
Thanks
 
Last edited by a moderator:
solution

I found this on groups.google

"createElement always adds an empty namespace-attribute.
The solution i found is:

Use the createnode-method and set the namespace of the element to the
namespace e.g. of the root-element. "

try this:
XMLDocument.CreateNode(XmlNodeType.Element, "", elem.QualifiedName.Name, XMLDocument.DocumentElement.NamespaceURI)


it worked for me.

-lp
 
Back
Top