473,378 Members | 1,391 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.

Element specified

Hi,

it is possible to have a variable of the same name as an element, with the
word `Specified' appended, to control whether the element is serialized or
not. I'm using XmlSerializer, and a class with `Specified' elements may
look like this (in CS):

public class Units
{
public Units() { }
public Units(Metric m) { Metric = m; m_MetricSpecified = true;}
public Units(Imperial i) { Imperial = i; m_ImperialSpecified = true; }

[XmlIgnore] public bool m_MetricSpecified = false;
private Metric m_Metric;
[XmlElement(Type=typeof(Metric),ElementName="Metric ",IsNullable=false)]
public Metric Metric
{
get { return m_Metric; }
set {m_Metric = value; m_MetricSpecified = true; m_ImperialSpecified
= false; }
}

[XmlIgnore] public bool m_ImperialSpecified = false;
private Imperial m_Imperial;

[XmlElement(Type=typeof(Imperial),ElementName="Impe rial",IsNullable=false)]
public Imperial Imperial
{
get { return m_Imperial; }
set { m_Imperial = value; m_MetricSpecified = false;
m_ImperialSpecified = true; }
}
}

I'm not sure the `m_' is allowed on the `Specified' variables. Where can I
find information about this way of specifying elements? I want to do it on
a MC++ class but I can't find any information.
Thanks!

--
Daniel
Nov 12 '05 #1
0 814

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

Similar topics

1
by: ranma79 | last post by:
Hi, I was wondering if anyone knows if this is possible. I have the following simple xml document as follows: <test> <field1>Value1</field1> <field2>Value2</field2> </test>
2
by: Robert Zurer | last post by:
I want to create a schema element that will allow any element as a child but that child must contain specified attributes This example doesn't work but it might give an idea of what I need to do....
1
by: Paul Gobée | last post by:
What is the parent element of a button (IE6 on Win, transitional mode)? Is it the BODY, the browser default stylesheet, or something else? Contra "body is parent-element": - Buttons with no...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
2
by: Michal Januszczyk | last post by:
I have a very simple XML document. <SmtpGatewayRules xmlns="http://www.foo.com/schema.xsd"> <rules> <rule> </rule> </rules> </SmtpGatewayRules> When no xmlns is specified I can find rule...
13
by: Fernando Deutsch | last post by:
I have an html page with an iframe on it. Inside the iframe there is an img element. I am looking how to reference the iframe from the img element contained on it and cannot find a way to do it. I...
2
by: gisleyt | last post by:
Is it possibly to specify that I want a either a element or an attribute to occur, but not both at the same time? <xs:complexType name="foo"> <xs:sequence> <xs:element minOccurs="0" ref="bar"/>...
28
by: Andy Dingley | last post by:
What specifies the permitted root element(s) for a document ? HTML, SGML, XHTML or XML ? Valid HTML documents need to have a well-known DTD and a doctypedecl in each document like this:...
4
by: Eric | last post by:
Attached is an example of my question. Note the "values" attribute is optional. Also the <valuesub-element is optional. Here, the XML can contain, 1 or both or neither. I would like to allow...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.