Nicholas:
Thanks for the reply, but I guess I forgot to mention that I'm new to this
stuff. "Xpath query"? How do I do that? Maybe a simple example would
make
my question more clear:
Suppose I have a class as follows:
[Serializable] public class foo {
public string member1;
public string member2;
};
And, I serialize it as follows:
...
foo xx = new foo();
xx.member1 = "test value";
xx.member2 = "test value2";
FileStream fs = new FileStream("test.xml", FileMode.Create);
SoapFormatter s = new SoapFormatter();
s.AssemblyFormat =
System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Simple;
s.Serialize(fs, foo);
fs.Close();
So, now I have a file, "test.xml", and I want to pull out the value of
"member1", without deserializing the file into a new instance of foo. How
do I do that?
- Dave
in
message news:
[email protected]...
Dave,
The xml that the XmlSerializer generates for a particular type should be
pretty consistent. I would say to take a look at the output that the
type
that you are serializing generates, and then construct an XPath query
that
you can use to get the value.
For primitive value types, this should be fine, but for propreties that
return class instances, you might have no other option than to run the
XmlSerializer on the whole thing.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Dave said:
I am saving a class by giving it the "Serializable" attribute, and calling
Serialize. Is there a way that I can pull the value of an individual
member
of the class, out of the resulting xml file, without constructing a new
instance of the class deserializing the file into it? In this case, I
just
need the value of a string member, and don't want to construct the entire
class to get it.