find tagname from property with reflection

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hy.<br/>
<br/>
I have creates a .cs object model from an xsd.<br/>
<br/>
My problem is:<br/>
<br/>
is possible from the serialization attributes of a class or of a property get the name of the tag of the xml <tagxml>xxxvalue</tagxml> associated to the property or to the class?<br/>
<br/>
With reflection im can access to attributes , but i dont know what attribute i must use.
i see that XmlElementAttribute does this , but what it means if there are more than one XmlElementAttribute?<br/>
like this code, generated from xsd .net 2.0:

<pre lang="x-c# [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.iai-tech.org/ifcXML/IFC2x3/FINAL")]
public partial class IfcRelAssignsToProductRelatingProduct
{

private IfcProduct itemField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("IfcAnnotation", typeof(IfcAnnotation), IsNullable = true)]
[System.Xml.Serialization.XmlElementAttribute("IfcGrid", typeof(IfcGrid), IsNullable = true)]
[System.Xml.Serialization.XmlElementAttribute("IfcProduct", typeof(IfcProduct), IsNullable = true)]
[System.Xml.Serialization.XmlElementAttribute("IfcProxy", typeof(IfcProxy), IsNullable = true)]
public IfcProduct Item
{
get
{
return this.itemField;
}
set
{
this.itemField = value;
}
}
}[/code]
<br/>
<br/>

I use the vs 2008.
Thanks.
<br/>
<br/>

View the full article
 
Back
Top