Need help with API Values in XElement
-
Bootzilla33 wrote:
I asked this question in another thread but no one answered it so I'm creating a new thread to see if someone can help. I need help with pass the value in the API to XElement in C# Here the a piece of the API schema:
<xsd:element
name="EventStatus" type="xsd:string">
xsd:annotation\
xsd:documentation\Event Status</xsd:documentation>
</xsd:annotation>
</xsd:element>Is this how that would be done?
new XElement("EventStatus", "Event Status"),
), -
Bootzilla33 wrote:
I asked this question in another thread but no one answered it so I'm creating a new thread to see if someone can help. I need help with pass the value in the API to XElement in C# Here the a piece of the API schema:
<xsd:element
name="EventStatus" type="xsd:string">
xsd:annotation\
xsd:documentation\Event Status</xsd:documentation>
</xsd:annotation>
</xsd:element>Is this how that would be done?
new XElement("EventStatus", "Event Status"),
),Your question is not very clear, but I assume you want to create an XElement that when written to a file will look like this
Event Status
This is one way to do it.
XNamespace ns = "should probably be the XSD namespace";
XElement documentation = new XElement(ns + "documentation");
documentation.SetValue("Event Status");XElement annotation = new XElement(ns + "annotation");
annotation.Add(documentation);XElement eventStatus = new XElement(ns + "element");
eventStatus.SetAttributeValue(XName.Get("name"), "EventStatus");
eventStatus.SetAttributeValue(XName.Get("type"), "xsd:string");
eventStatus.Add(annotation);XElement root = new XElement("root", new XAttribute(XNamespace.Xmlns + "xsd", ns));
root.Add(eventStatus);string s = root.ToString(); // Just a debug test line