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

XPath & Serialization?

Hi,
Ive got a problem with something im working on. I have some Xml
that i am Deserializing in to two classes but im not convinced there
is not a better way. One of the classes is purely serving to mimic the
structure of the Xml rather then serving any useful purpose so i would
like to eliminate it but im having a bit of trouble finding the right
method on the serializer to eliminate it.

The Xml looks a bit like:
<nodea>
<nodeb>
<nodec />
<noded />
</nodeb>
</nodea>
and the current C# looks like:

//Holds nodea
public class nodea
{
[XmlElement("nodeb",typeof(nodeb))]
public nodeb dataholder;

//Method to get nodec from dataholder
[XmlIgnore]
public string nodec
{
get {return this.dataholder.nodec;}
set {this.dataholder.nodec = value;}
}

//Method to get noded from dataholder
[XmlIgnore]
public string noded
{
get {return this.dataholder.noded;}
set {this.dataholder.noded = value;}
}
}

//Holds node data
public class nodeb
{
[XmlElement("nodec",typeof(string))]
public string nodec;

[XmlElement("noded",typeof(string))]
public string noded;
}
What i would really like to be able to do is eliminate the nodeb class
and just have the nodec & noded values written to the apropriate
string members of class nodea but like i said i cant figure out how to
do it. Is there a way to pass Xpath through the XmlElement method to
tell it to get the value from elsewhere in the tree or is there some
other method entirely i can use?

Many many many many thanks in advance for your responses,

Liam Leane
Nov 16 '05 #1
0 1083

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

Similar topics

0
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings...
1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
0
by: Michael Fork | last post by:
Note: I pasted the code the attachments as plain text after the message (I wasn't able to post it with an attachment...) Attached are the XSL and XML files that I am having problems with. I am...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
1
by: Robert | last post by:
I am having a problem selecting nodes using the XMLnodelist Selectnodes using XPATH when I use XML SPY is successfully queries but when is use VB.net it comes up with nothing. Here is my code ...
1
by: CodeMonkey | last post by:
Hi, I am reading values from an Xml file using XPathDocument / NodeIterators etc. My question is, is it possible to retrieve the XML for a node as a string so that i can use XML Serialization...
1
by: thomasv | last post by:
Hi, I want to convert the following XML (OpenOffice Calc file): <?xml version="1.0" encoding="UTF-8"?> <office:document-content ...
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...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.