xml serialize properties

I am having a problem serializing an object.  I have a very simple
class.

	[Serializable]
	public class Phone : SwcDomainObject
	{
		private string areaCode;
		private string prefix;
		private string suffix;
		private string extension;

		public string AreaCode
		{
			get { return areaCode; }
			set { areaCode = value; }
		}

		public string Prefix
		{
			get { return prefix; }
			set { prefix = value; }
		}

		public string Suffix
		{
			get { return suffix; }
			set { suffix = value; }
		}

		public string Extension
		{
			get { return extension; }
			set { extension = value; }
		}

		public string FullPhone
		{
			get{return this.areaCode + " " + this.prefix + " " + this.suffix;}
		}

	}
OUTPUT:
<PhoneWork>
  <AreaCode>252</AreaCode>
  <Prefix>332</Prefix>
  <Suffix>4117</Suffix>
</PhoneWork>

Everything serializes fine except for the FullPhone Accessor.  When
that serializes it doesn't hold the value in the xml document.  I can
only assume since you are using the  xml serialization as more of a
state holder.  That function accesors are not serialized only static
primitive datatypes?  Is there anyway I can force the serialization to
occur on this accessor?

TIA

JoSkillz

0
ocampoj (2)
9/5/2005 8:46:10 PM
dotnet.xml 7266 articles. 0 followers. Follow

1 Replies
512 Views

Similar Articles

[PageSpeed] 39

Never mind I figured it out.  In order for any of the object properties
to be serialized in XML they must expose both a setter and getter.

0
ocampoj (2)
9/6/2005 3:01:03 AM
Reply:

Similar Artilces:

Parsing custom tag in XML node ??
Hi All, I have a piece of HTML stored in a CDATA xml node, and would like a way to provide the content-editor who's enters the text a friendly way to specify a search query, something like: <ROOT> <bodytext><![[CDATA[this is a example of the <b>HTML</b> text.<br> Click <searchbyname arg="john">Here</searchbyname> to get John's search results, or click <searchbyID arg="111">Here</searchbyID> to search by ID. </bodytext> </ROOT> I figured that <searchbyname> and <searchb...

XML Source Menu Item disabled?? File version??
My XML Source Menu Item is disabled (aka greyed-out). Why? I have a workbook with multi-worksheets and I want to enable a conversion to XML, I'm trying to follow the documentation here, but it's poorly organized and more poorly written (IMHO).. I can't find anything which tells me why the menu item would be disabled. The version is Office 2003 Pro and (clearly) the capability is there, I can see the "XML Source" item. I did a quick test and if I make a brand new file, I have the XML Source option so that means means this is a file version issue?. I know this wo...

get xml option in data menu
i can't find the xml option in the data menu? any ideas? using office 2003 sbe. ...

Deserializing XML feed (nested array problem)
Hiho, I'm trying to deserialize the following XML feed from the weather channel but I'm having an issue with the nested arrays. I got as far as getting the 'day' into arrays but I can't get the 'part' nested array working. This is my first hack at XML feeds and such, so any pointers as to how to best do this or references/tutorials would be good. (I'm doing all this in .NET 2.0 btw) Ok, here's a snip of the feed: <weather> <loc>...</loc> <cc>...</cc> <dayf> <day d="1" t="Tuesday" dt="Jul 27&...

Printing Document Properties
When I print an Excel 2000 document, I would like to print out the file's properties too. I can't find an option in Excel to do this. Is this possible? Thanks, John http://support.microsoft.com/kb/q190029/ "AnytimeAnywhere" wrote: > When I print an Excel 2000 document, I would like to print out the file's > properties too. I can't find an option in Excel to do this. Is this > possible? > > Thanks, > > John > > > ...

Hide email address properties
when a user doubles clicks a name in the global address list (from outlook) they can see users phone number, mobile number.... I would like to disable the option the view properties, or the Phone/Notes tab any help is greatly appreciated. Remove the appropriate fields from the Display Template(s). This may help: HOW TO: Modify Display Template to make default email address appear in Address Book/GAL http://exchangepedia.com/blog/2006/11/how-to-modify-display-template-to-make.html -- Bharat Suneja MVP - Exchange www.zenprise.com NEW blog location: exchangepedia.com/blog ---------------...

xml schemalocation
I'm trying to generate a schemalocation entry on my root node when using the xmlserializer.serialize method. I have been unable to achieve this. Is there a certain attribute I need to be applying to my root node class for that to appear? Any help is appreciated. Lance Johnson How about: public class Test { [XmlAttribute("schemalocation")] public string Location; } "Lance Johnson" <ljohnson@docs.com> wrote in message news:ud$OUCzsFHA.2076@TK2MSFTNGP14.phx.gbl... > I'm trying to generate a schemalocation entry on my root node when using the &...

Problem in communicating with the serial printer
Hi all, I have connected my printer in com port(com1), and create a handle to the com port using createfile function to which the printer is connected.I checked the handle returned by CreateFile() for INVALID_HANDLE_VALUE,it is ok.But the function GetCommState(hCOM, &dcb),Setcommtimeouts are failing. But once I disable and enable the com ports in the device manager manually,the functions GetCommState(hCOM, &dcb),Setcommtimeouts are getting succeded. T his also works until I delete the printer driver / restart the system,if I install again, I need to disable and enable th...

Array to Xml to DataSet
I have an array of objects (my own custom class). I'm trying to convert that array to a dataset. So I serialize the array to XML, then try to load the XML to a dataset. MemoryStream mem = new MemoryStream(); XmlTextWriter w = new XmlTextWriter(mem,System.Text.Encoding.UTF8); ser.Serialize(w,books); XmlTextReader r = new XmlTextReader(mem); DataSet dsBooks = new DataSet(); dsBooks.ReadXml(r); <=== error here However, the last line generates System.Xml.XmlException. Additional info is "System Error". Does anyone know the best way to do this? I prefer not to write to dis...

XML Entity problem
Hi, I am still new to XML and thought I had my solution written, but during the rollout, we have come up with a problem with actual XML coming in (as opposed to our test XML). Some character entities have been transmitted unexpectedly. &apos; and &lt; I am loading my XML with XmlDocument, just by XmlDocument xDoc = new XmlDocument(); xDoc.Load(IncomingFilePath + e.Name); e is an incoming Fileinfo. My XML does not have any declaration at the top for a DTD. I always thought &apos; and &lt; were understood, but obviously not. The first line of my incoming XML is <?xml...

Switching tabs on a property sheet programmatically
when I attempt to switch tabs programmatically on a property sheet, I use m_tab->SetCurSel(tab). The tab will switch, but the list control on the tab will not update unless I physically click on the tab. I have tried using m_pListCtrl->Invalidate() after the call to SetCurSel. I have also tried sending a WM_PAINT message to the list control. The following is the signature for the handler for the tab switch: void CAlarmWindow::OnSelChangeTab(NMHDR* pNMHDR, LRESULT* pResult) and the following is the MESSAGE_MAP entry for the handler: ON_NOTIFY(TCN_SELCHANGE, IDC_ALARM_TAB, OnSel...

XML processing instruction and Standalone property
I used dataset to merge 2 XML files having the same structure. I managed to merge these 2 XML files but how can I write a processing instruction to link the merged file to the existing XSL document? Before merging the merging, each XML file has a processing instruction to link to XSL stylesheet. But after the merging, I cann't specify the standalone property and processing instruction. This is how I merge 2 XML files: ds1.Merge(ds2, True) ds1.WriteXml(OutputFileName, XmlWriteMode.IgnoreSchema) How should I do so that the Output file will have the processing instruction and set t...

object serialization array at base level
Hello, I am trying to use serialization to get an XML document in the following format <allevents> <event> <title>hello</title> <media> <type>hello</type> </media> <media> <type>world</type> </media> <event> </allevents> My objects looks like this (with some details missing) class @event { [XmlElement("title")] public string title { get; set; } [XmlArray("media")] public media[] Media { get; set; ...

Simplest Way to Deal With XML?
Dear : I need a simple way to deal with XML , like that found in .NET XmlDocument, is there any available class. Regards Have a look at www.codeguru.com there are some nice wrapper classes. M "Raed Sawalha" <raed_sawalha@hotmail.com> wrote in message news:uaO0IR5rEHA.644@tk2msftngp13.phx.gbl... > Dear : > > I need a simple way to deal with XML , like that found in .NET > XmlDocument, > is there any available class. > > Regards > > Use MSXML and the interfaces provided by it. It would definately help you to deal with XML. "M" &l...

Form's Dirty property...
I have a Form that has multiple controls on it. I want to detect if any of the information in any of the controls has changed. So, when the user goes to close the form I check the Me.Dirty property. If it's True then I want to save the data. The problem is that I can make changes and the form never comes back with Me.Dirty = True. Is there something that I am missing? Thanks. Joe wrote: >I have a Form that has multiple controls on it. I want to detect if any of the >information in any of the controls has changed. So, when the user goes to >close the form I check the Me...

Custom form for specified Document Properties
Under Word 2007, by default, there's a huge number of keystrokes required to get to Custom Document Properties. I'd like to make this simple. Two ways forward have thwarted me, esp. since Word Help is no longer working properly for me (I'm getting empty Office 2010 stuff - subject of a separate post.) i) build a form (I've forgotten how to do this.) ii) explore the opportunities suggested by the ribbon under Developer|Templates|Document Panel. The dialog box that opens looks like it might supply what I want. Normally, the Help system would send me where I wa...

how to return a serial number to a date
Example: 40899 Is there a formula to convert the serial number 40899 above back to 12/22/2011? Thanks, Holly Format the cell as Date -- Biff Microsoft Excel MVP "Holly" <Holly@discussions.microsoft.com> wrote in message news:82F628DD-B506-4A72-B5AC-DF85265ADAB0@microsoft.com... > Example: 40899 > > Is there a formula to convert the serial number 40899 above back to > 12/22/2011? > > Thanks, Holly "Holly" wrote: > Is there a formula to convert the serial number 40899 > above back to 12/22/2011? It would h...

Is this possible with xml web control ?
Hi all, I am trying to use the xml control in a asp.net page. What i want to be able to do is to store the data in xml format between two pages and finally send this xml data to sql server database. I am wondering is it possible to store data without actually creating a xml file ? If so how this should be done..? any samples or direction as to how this should be done is greatly appreciated.. TIA, sri Thanks Victor..I appreciate your help. "Victor Garcia Aprea [MVP]" <vga@NOobiesSPAM.com> wrote in message news:e98iKABSDHA.1304@TK2MSFTNGP11.phx.gbl... > Hi sri, > >...

SQL 'for xml' and C# example??
I'm missing some piece of the puzzle. I'm using 'for xml' type queries from SQL2K - and now trying to change the front-end from ADO to C#, I can't quite figure it out.. It seems that I could use an XmlReader.. and somehow use that instead of a DataReader.. but that didn't work.. I tried using a DataReader and get the byte array - but that wasn't right. SQL returns formatted XML, I need to load that XML into an XmlDocument somehow without ANY molestation of that dom. Any ideas? Examples? Missing links???? thanks THANKS!! I've been looking for the answer to ...

I have Excel 2003, click on Data....no XML!?
I am in a computer fundamentals class which includes Excel, however when the assignment was to import the schema file and create the XML map after clicking DATA on the menu bar, there was no XML to point to. Is it a foopah in Excel 2003 program? This may help answer your question. http://www.mrexcel.com/tip064.shtml "sarah_rose" wrote: > I am in a computer fundamentals class which includes Excel, however when the > assignment was to import the schema file and create the XML map after > clicking DATA on the menu bar, there was no XML to point to. Is it a foopah...

send and receive XML in a web application
Hello, I new in XML inside .NET, and I looking the best way to send and receive XML, how you work this? WSE 2.0 is the recomendable? Thanks ...

Invalid XML. Missing required tag <CodeGroup>
I have this error, calling every aspx file, when I switch the app pool from 64 to 32 bit. I've tested the same web site on an other similar server, and I haven't any error, so I think there is something wrong on the server config, but I can understand what. I have many other web sites, 64 and 32 bit, and they run without problem. I've tried to switch to full trust the web site, but still the same. someone can help me? thanks System.ArgumentException: Invalid XML. Missing required tag <CodeGroup> for type 'System.Security.Policy.PolicyLevel' ...

Serialization of array of structs
I have an array of structs which I am serializing. Is there a tag I can use to change the name of the struct members in the output XML? I know I can change the root node name with: [XmlArrayAttribute("LogInfo")] private LogInfo[] m_arrLogInfo; But how do I change the name of the members? Try XmlArrayItem: http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xmlarrayitemattribute.aspx Chris Ashley wrote: > I have an array of structs which I am serializing. Is there a tag I can > use to change the name of the struct members in the output XML? I know >...

Error deserializing previously serialized object
I've used XMLSerializer before to store user settings with great success, but this is the first time I've tried to serialize an Array. It serializes fine, but when I try to deserialize it, I get the following error: There is an error in XML document (0, 0). ---> System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1. As I've done this before, I'm at a loss to explain it. Here is the xml produced by the serialization routine: <?xml version="1.0" encoding="utf-8"?> <DataGridProperties xmlns:xsd="http://www.w3.or...

USB Serial Comms
I have a serial comms application that one of my customers has started using with a USB serial comms port. So far, so good. Everything works fine except, there's always an "except", from time to time the USB cable works loose (or is more likely disconnected - bloody customers, who'd have them). At this point my application usually ends up in a tailspin and requires a restart (ouch), sometimes the system requires restarting (OUCH). I have higher standards than that, hence me being here looking for help, and my customer doesn't like restarting although he seems l...