Connecting Tech Pros Worldwide Help | Site Map

xsi:noNamespaceSchemaLocation Problem

  #1  
Old August 7th, 2008, 11:05 PM
Samuel
Guest
 
Posts: n/a



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


  #2  
Old August 8th, 2008, 08:25 AM
Joe Fawcett
Guest
 
Posts: n/a

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

  #3  
Old August 8th, 2008, 02:45 PM
Samuel
Guest
 
Posts: n/a

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


  #4  
Old August 8th, 2008, 03:05 PM
Martin Honnen
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlDocument xsi: Problem Mark Jerde answers 1 November 17th, 2005 06:23 AM
XmlDocument xsi: Problem Mark Jerde answers 3 November 12th, 2005 04:46 AM
Validation Problem Harry_Crow answers 6 November 12th, 2005 04:41 AM
Validation error The 'xsi:noNameSpaceSchemaLocation' attribute is not declared AP answers 1 November 12th, 2005 03:16 AM