XMLNameSpaceManager.AddNamespace and XMLParserContext

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

    #1

    XMLNameSpaceManager.AddNamespace and XMLParserContext

    If there's a better place to ask, please advise. I've serialized a custom
    collection class using the XMLSerializer, and now I'd like to deserialize
    it. The xml representation of the serialized collection of MyCustomObject
    was never written to disk; I'm working with MemoryStream and strings. I have
    the XML document in a string:


    <?xml version="1.0" encoding="utf-8"?>\'0d\'0a<Ar rayOfMyCustomOb ject
    xmlns:xsd="http ://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">\'0d
    \'0a <MYCUSTOMOBJECT >\'0d\'0a
    <FieldID>4f5c0e 3b-2492-4b9b-a43a-5e48396bb930</FieldID>\'0d\'0 a
    <Name>Cities of the World</Name>\'0d\'0a

    ... etc etc etc

    </MYCUSTOMOBJECT>
    </ArrayOfMyCustom Object>

    Given the above XML document as a string, how do I add a namespace to the
    XMLNamespaceMan ager and set up the XMLParserContex t?


    Dim nt As NameTable = New NameTable
    Dim nsmgr As XmlNamespaceMan ager = New XmlNamespaceMan ager(nt)

    nsmgr.AddNamesp ace(?,?)

    '// ???
    Dim context As XmlParserContex t = New XmlParserContex t(Nothing, nsmgr,
    Nothing, XmlSpace.None)

    '// variable "info" contains the XML document as a string
    Dim Reader As New XmlTextReader(i nfo, XmlNodeType.Doc ument, context)


    Thanks for the help!
    Timo


Working...