473,378 Members | 1,507 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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<ArrayOfMyCustomObject
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\'0d
\'0a <MYCUSTOMOBJECT>\'0d\'0a
<FieldID>4f5c0e3b-2492-4b9b-a43a-5e48396bb930</FieldID>\'0d\'0a
<Name>Cities of the World</Name>\'0d\'0a

... etc etc etc

</MYCUSTOMOBJECT>
</ArrayOfMyCustomObject>

Given the above XML document as a string, how do I add a namespace to the
XMLNamespaceManager and set up the XMLParserContext?
Dim nt As NameTable = New NameTable
Dim nsmgr As XmlNamespaceManager = New XmlNamespaceManager(nt)

nsmgr.AddNamespace(?,?)

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

'// variable "info" contains the XML document as a string
Dim Reader As New XmlTextReader(info, XmlNodeType.Document, context)
Thanks for the help!
Timo
Nov 21 '05 #1
0 1152

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Oisin Grehan | last post by:
Hi, I can't for the life of me get this to work properly. I've searched for examples, but none of the examples quite match my environment. Here is my XML (please treat this as immutable -- no...
1
by: Dan via .NET 247 | last post by:
Hi All, Is it possible to serialize an instance of XmlNamespaceManager? I'd like to use it to manage a collection of namespaces and savethat collection for later use but when attempting to...
0
by: Victor Hadianto | last post by:
Hi All, I have the following code:
1
by: Victor Hadianto | last post by:
Hi All, I have the following code: <snip> XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(@"<?xml version=""1.0"" encoding=""UTF-8""?> <myConfig:myConfig...
3
by: S | last post by:
I'm having a problem attaching a name space. I'm getting an xml string of information as a result of a third party web service. I can't change the format of the string. The xml file looks like...
1
by: Brian Cobb | last post by:
Greetings; I have an application where I am receiving HTML fragments containing snippets (sub-fragments?) of XML. I wish to extract the XML bits for further processing. In the process of...
9
by: Richard L Rosenheim | last post by:
I'm trying to query a XML file that was created via ADO.NET. My query wasn't returning anything, and I tracked the problem to an issue with the namespace that ADO.NET specified. When I remove the...
0
by: Jen | last post by:
My main question: "How can I get a TextReader or Stream object from an existing XmlReader?". Read on for more: I have an existing XmlReader. Let's call it reader1. I'm creating another reader,...
1
by: peterloh | last post by:
Hi, I'm trying to read a simple Word 2007 document with the contents of "This is a test." Could someone please enlighten me about why the following code doesn't work... Dim strXMLDocument...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.