Connecting Tech Pros Worldwide Forums | Help | Site Map

xsi:noNamespaceSchemaLocation Problem

Samuel
Guest
 
Posts: n/a
#1: Aug 7 '08



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



Joe Fawcett
Guest
 
Posts: n/a
#2: Aug 8 '08

re: xsi:noNamespaceSchemaLocation Problem




"Samuel" <samuel.shulman@ntlworld.comwrote in message
news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
Quote:
>
>
>
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

Samuel
Guest
 
Posts: n/a
#3: Aug 8 '08

re: xsi:noNamespaceSchemaLocation Problem





"Joe Fawcett" <joefawcett@newsgroup.nospamwrote in message
news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...
Quote:
>
>
"Samuel" <samuel.shulman@ntlworld.comwrote in message
news:O3KgGkN#IHA.3852@TK2MSFTNGP05.phx.gbl...
Quote:
>>
>>
>>
>I use the following code to create the XML from a class object
>>
> Dim serialize As New
>System.Xml.Serialization.XmlSerializer(GetType(XY ZObject))
> 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


Martin Honnen
Guest
 
Posts: n/a
#4: Aug 8 '08

re: xsi:noNamespaceSchemaLocation Problem


Samuel wrote:
Quote:
"Joe Fawcett" <joefawcett@newsgroup.nospamwrote in message
news:%23RopSZS%23IHA.5036@TK2MSFTNGP04.phx.gbl...
Quote:
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/libr...serialize.aspx
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/
Closed Thread