Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Need help with API Values in XElement

Need help with API Values in XElement

Scheduled Pinned Locked Moved XML / XSL
questioncsharpdatabasexmljson
2 Posts 2 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bootzilla33
    wrote on last edited by
    #1

    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"),
     
    ),

    G 1 Reply Last reply
    0
    • B Bootzilla33

      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"),
       
      ),

      G Offline
      G Offline
      George Jonsson
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups