xsi:noNamespaceSchemaLocation Problem
Question posted by: Samuel
(Guest)
on
August 7th, 2008 11:05 PM
I use the following code to create the XML from a class object
Dim serialize As New
System.Xml.Serialization.XmlSerializer(GetType(XYZ Object))
serialize.Serialize(obWtiter, obObject)
But I need the following ' xsi:noNamespaceSchemaLocation="obj-envelope.xsd"'
to be included in the in the main opening tag
How can I cause the XmlSerializer to do that?
Thank you,
Samuel
3
Answers Posted
"Samuel" <samuel.shulman@ntlworld.comwrote in message
news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
>
>
>
I use the following code to create the XML from a class object
>
Dim serialize As New
System.Xml.Serialization.XmlSerializer(GetType(XYZ Object))
serialize.Serialize(obWtiter, obObject)
>
>
But I need the following '
xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' to be included in the in
the main opening tag
>
How can I cause the XmlSerializer to do that?
>
Thank you,
Samuel
>
This seems to be what you are looking for:
http://johnstewien.spaces.live.com/blog/cns!E6885DB5CEBABBC8!888.entry
--
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
"Joe Fawcett" <joefawcett@newsgroup.nospamwrote in message
news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
>
>
"Samuel" <samuel.shulman@ntlworld.comwrote in message
news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
>>
>>
>>
>I use the following code to create the XML from a class object
>>
> Dim serialize As New
>System.Xml.Serialization.XmlSerializer(GetType(XYZ Object))
> serialize.Serialize(obWtiter, obObject)
>>
>>
>But I need the following '
>xsi:noNamespaceSchemaLocation="obj-envelope.xsd"' to be included in the
>in the main opening tag
>>
>How can I cause the XmlSerializer to do that?
>>
>Thank you,
>Samuel
>>
This seems to be what you are looking for:
http://johnstewien.spaces.live.com/blog/cns!E6885DB5CEBABBC8!888.entry
>
--
>
Joe Fawcett (MVP - XML)
http://joe.fawcett.name
Thank you for the link,
I managed to add the xsd reference
The actual code didn't work so I wonder how can I set the encoding that the
serelizer will use
Thank you,
Samuel
Samuel wrote:
Quote:
Originally Posted by
"Joe Fawcett" <joefawcett@newsgroup.nospamwrote in message
news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
The actual code didn't work so I wonder how can I set the encoding that the
serelizer will use
The Serialize method has several overloads
http://msdn.microsoft.com/en-us/lib...erialize.a spx
if you pass in a TextWriter it will use the encoding of the TextWriter,
if you pass in an XmlWriter you can set the encoding with the
XmlWriterSettings you create the XmlWriter with:
Dim wSettings As New XmlWriterSettings()
wSettings.Encoding = Encoding.UTF8
Using xWriter As XmlWriter = XmlWriter.Create("file.xml", wSettings)
serializer.Serialize(xWriter, someObject)
End Using
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 197,004 network members.
Top Community Contributors
|