473,326 Members | 2,168 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,326 software developers and data experts.

XML Deserialize question

Hi,
I have a huge XML file, and only part of the section will be used as my
config setting. Is it possible to deserialize this section only from this
huge XML file?

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
Nov 16 '05 #1
3 2839
Yes. Use a sax parser, when you hit the section you care about, save it
into a string until you reach the end of the section. After you've got what
you want, load it into memory and away you go.

Robert

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
Hi,
I have a huge XML file, and only part of the section will be used as my
config setting. Is it possible to deserialize this section only from this
huge XML file?

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy

Nov 16 '05 #2
Thanks for your reply, could you give me more detail. .Net framework does
not support SAX, at least I do not find classes for SAX.
"Robert May" <ra****************@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP15.phx.gbl...
Yes. Use a sax parser, when you hit the section you care about, save it
into a string until you reach the end of the section. After you've got what you want, load it into memory and away you go.

Robert

"Hardy Wang" <ha*******@hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP09.phx.gbl...
Hi,
I have a huge XML file, and only part of the section will be used as my config setting. Is it possible to deserialize this section only from this huge XML file?

--
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy


Nov 16 '05 #3
"Hardy Wang" <ha********@marketrend.com> wrote in message news:Oe**************@TK2MSFTNGP14.phx.gbl...
.Net framework does not support SAX, at least I do not
find classes for SAX.


This is correct, the .NET Framework doesn't support SAX.

Instead, it supports a pull model streaming XML processing
API, through it's XmlReader and XmlWriter classes in the
System.Xml namespace.

What you'll probably need to do is subclass XmlTextReader.

It's still necessary to 'read' the whole file up to that point with
these classes, but what you avoid is building up the internal
structures supporting a DOM node tree for the XML content
you don't care about. That's why it can perform better.

Override the properties to detect (through some combination
of LocalName and NamespaceURI for that portion of the doc
you care about) when you enter the region of interest ... raise
a flag. In your overrides of other methods, capture the info
read while this flag is raised until you leave the region of
interest.

A Stack from the System Collections namespace is useful
here to track as you descend and ascend the node tree.
Derek Harmon
Nov 16 '05 #4

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

Similar topics

4
by: Bob Rock | last post by:
Hello, I've got an xml stream that I'd need to deserialize into an instance of a given class A. I'd like to create an instance method on class A (method Deserialize) that takes this XML stream...
7
by: Ian Tompsett | last post by:
H I was wondering if it possible for an object to serialize/deserialize itself from XML. I'd be guessing that it would need to use the XmlSerializer class, but that seems to want to create a...
2
by: Greg | last post by:
I'm writing a class in C# .... I have a collection calls Reports made up of Report objects. I'm trying to deserialize an XML file that looks like : <Reports> <Report> <Title>some title</Title>...
1
by: Alex | last post by:
I am creating an application that allows the user to link a plug-in "utility" class (Watcher) to a class at runtime. There are several Watcher utilities, each with a different style of "watching"...
0
by: Fred Heida | last post by:
Hi Al, i have a funny problem.. i you can call it funny.. what i have is 2 assemblies, the first one does nothing other then Application.Run(new MyForm())
7
by: MP | last post by:
Hi, I would like to be able to deserialize a stream to a specific instance. Deserialize returns me a new instances and that is not really what we need, we need to deserialized to an existing...
2
by: Thomas S | last post by:
Any suggestions on how to deserialize an object from one line of XML? I'm trying to deserialize multiple objects from one XML document, each object on one line of the file. The serialization is...
1
by: Yewen Tang | last post by:
I have a schema file datamodel.xsd, element "properties" is declared as a type of "baseProperty". The schema file also defines "derivedProperty" is a derived type of "baseProperty". <?xml...
4
by: Anbu | last post by:
Hi All, I need to Deserialize the SoapService's SoapEnvelope response object. Here is the Body of the SoapEnvelope received as respone, <q1:serviceResponse...
1
by: Tony Johansson | last post by:
Hello! Assume I have a class called Product which is defined with the attribute I create a collection by using the generic class List in this way List<Productproducts = new List<Product>(); ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.