Im working on an project where I use an autogenereted vb class. I want to serialize this class to an xml file. When I validate my xml file against my xsd fil I get an error: Cannot Find The Declaration Of Element 'message'.
My xsd looks like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tera="http://tera.net/xsd/data"
xmlns:ns1="http://tera.net/xsd/Company-dok/note/2010"><xsd:element name="Message"
type="TestMessage" /><xsd:complexType
name="TestMessage"><xsd:sequence><xsd:element name="Detail" type="Detail" /> ........
My xml looks like:
<?xml version="1.0" encoding="utf-8"?>
<message xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:ska:test:micro:v2">
But it should look like this:
<?xml version="1.0" encoding="UTF-8" ?>
<message xmlns="urn:ska:test:micro:v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance" xsi:schemaLocation="urn:ska:test:micro:v2 test_v2_0.xsd">
What am I missing?
When I serialize my class to xml I want my elemts properties to appeare in my xml in a given order. This can I solve if I cange my autogenerated file. If I cange the order of the properties in the classes in the autogenerated file the atributes in the xml will appear in the correct order. But I do not want to change my autogenerated file, what can I do?
Part of my autogen file:
<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929"), _
System.SerializableAttribute(), _
System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Xml.Serialization.XmlTypeAttribute([Namespace]:="urn:ska:test:micro:v2")> _
Partial Public Class Detail
Private NameField As String
Private PhoneField() As Oppgavegiver
'''<remarks/>
Public Property name() As String
End Property
'''<remarks/>
Public Property phone() As integer
End Property
If I place Phonefield on top of nameField and phone property on top of name property I get the correct order in my xml, but I do not want to change the sutogenerated file.
What do I have to do?
Thanks in advance!