sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Samuel's Avatar

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
Joe Fawcett's Avatar
Guest - n/a Posts
#2: Re: xsi:noNamespaceSchemaLocation Problem



"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

Samuel's Avatar
Guest - n/a Posts
#3: Re: xsi:noNamespaceSchemaLocation Problem




"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


Martin Honnen's Avatar
Guest - n/a Posts
#4: Re: xsi:noNamespaceSchemaLocation Problem

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/
 
Not the answer you were looking for? Post your question . . .
197,004 members ready to help you find a solution.
Join Bytes.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.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors