Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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

<?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

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:

<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

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

<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

<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

Edited by PlausiblyDamp
Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...