Hola
Quiero crear un Extensible Storage a partir de xml, estoy usando el ejemplo del Revit SDK 2021,pero no se como continuar, aquí esta mi xml
Hi I want to create an Extensible Storage from xml, I am using the example from Revit SDK 2021, but I don't know how to continue, here is my xml
<?xml versión="1.0" encoding="UTF-8" ?>
<longitudequivalente>
<Diametro valor = "15">
<M_Codo_45>0.25</M_Codo_45>
<M_Codo_90>0.46</M_Codo_90>
<M_Te_angulo>1.01</M_Te_angulo>
<M_Te_recta>0.34</M_Te_recta>
<M_Reducer>0.18</M_Reducer>
<Valve_Angle>2.6</Valve_Angle>
<Ball_Valve>0.11</Ball_Valve>
<CheckValve>1.63</CheckValve>
<FootValve>3.59</FootValve>
</Diámetro>
<Diámetro valor = "20">
<M_Codo_45>0.31</M_Codo_45>
<M_Codo_90>0.64</M_Codo_90>
<M_Te_angulo>1.37</M_Te_angulo>
<M_Te_recta>0.4</M_Te_recta>
<M_Reducer>0.24</M_Reducer>
<Valve_Angle>3.66</Valve_Angle>
<Ball_Valve>0.15</Ball_Valve>
<CheckValve>2.43</CheckValve>
<FootValve>5.19</FootValve>
</Diámetro>
<longitudequivalente>
Solved! Go to Solution.
Solved by joshua.lumley. Go to Solution.
Solved by reylorente1. Go to Solution.
You do it via serialisation, and you'll need to write code to convert it into a schema structure (an entity) that is in turn stored in an element.
I would start with the simpliest possible example, like a text string that says "Hello World."
Hello,
I must convert xml to object, to do the serialisation? since I found this code in https://spiderinnet.typepad.com/
prívate const string SingleStringFiledName = "Almacen_Piezas_Hidraulicas";
public static void SetDataToElement(string id, object o, Element e)
{
SchemaBuilder sb = new SchemaBuilder(new Guid(id));
sb.SetSchemaName(id.Replace("-", ""));
FieldBuilder fb = sb.AddSimpleField(SingleStringFiledName, typeof(string));
XmlSerializer xml = new XmlSerializer(o.GetType());
using (StringWriter w = new StringWriter())
{
XmlSerializer(w, o);
Entity ent = new Entity(sb.Finish());
ent.Set<string>(SingleStringFiledName, w.ToString());
e.SetEntity(ent);
}
}
Stream stream = new FileStream(string_Default_GuidToAlias, FileMode.Create, FileAccess.Write);
DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary<Guid, string>));
serializer.WriteObject(stream, dict_GuidToAlias); stream.Close();
I use System.Runtime.Serialization.
Can't find what you're looking for? Ask the community or share your knowledge.