xsi:noNamespaceSchemaLocation Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Samuel

    xsi:noNamespaceSchemaLocation Problem




    I use the following code to create the XML from a class object

    Dim serialize As New
    System.Xml.Seri alization.XmlSe rializer(GetTyp e(XYZObject))
    serialize.Seria lize(obWtiter, obObject)


    But I need the following ' xsi:noNamespace SchemaLocation= "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

    #2
    Re: xsi:noNamespace SchemaLocation Problem



    "Samuel" <samuel.shulman @ntlworld.comwr ote in message
    news:O3KgGkN#IH A.3852@TK2MSFTN GP05.phx.gbl...
    >
    >
    >
    I use the following code to create the XML from a class object
    >
    Dim serialize As New
    System.Xml.Seri alization.XmlSe rializer(GetTyp e(XYZObject))
    serialize.Seria lize(obWtiter, obObject)
    >
    >
    But I need the following '
    xsi:noNamespace SchemaLocation= "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.spa ces.live.com/blog/cns!E6885DB5CEB ABBC8!888.entry

    --

    Joe Fawcett (MVP - XML)


    Comment

    • Samuel

      #3
      Re: xsi:noNamespace SchemaLocation Problem




      "Joe Fawcett" <joefawcett@new sgroup.nospamwr ote in message
      news:%23RopSZS% 23IHA.5036@TK2M SFTNGP04.phx.gb l...
      >
      >
      "Samuel" <samuel.shulman @ntlworld.comwr ote in message
      news:O3KgGkN#IH A.3852@TK2MSFTN GP05.phx.gbl...
      >>
      >>
      >>
      >I use the following code to create the XML from a class object
      >>
      > Dim serialize As New
      >System.Xml.Ser ialization.XmlS erializer(GetTy pe(XYZObject))
      > serialize.Seria lize(obWtiter, obObject)
      >>
      >>
      >But I need the following '
      >xsi:noNamespac eSchemaLocation ="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.spa ces.live.com/blog/cns!E6885DB5CEB ABBC8!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


      Comment

      • Martin Honnen

        #4
        Re: xsi:noNamespace SchemaLocation Problem

        Samuel wrote:
        "Joe Fawcett" <joefawcett@new sgroup.nospamwr ote in message
        news:%23RopSZS% 23IHA.5036@TK2M SFTNGP04.phx.gb l...
        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

        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
        XmlWriterSettin gs you create the XmlWriter with:
        Dim wSettings As New XmlWriterSettin gs()
        wSettings.Encod ing = Encoding.UTF8
        Using xWriter As XmlWriter = XmlWriter.Creat e("file.xml", wSettings)
        serializer.Seri alize(xWriter, someObject)
        End Using


        --

        Martin Honnen --- MVP XML

        Comment

        Working...