troubleshooting Question

XML Simple Question for C# Devs

Avatar of sbornstein2
sbornstein2 asked on
C#XMLJSON
11 Comments1 Solution116 ViewsLast Modified:
I need to get the following format for serializing XML but not sure how best to handle this.  Element tag needed:

<create-by-workflow>
    <workflow-name>Customer</workflow-name>
</create-by-workflow>

Right now I have two classes as such:

public class WorkflowRequestDto
{
    [XmlElement(Constants.CreateByWorkflowTagName)] //this is     public const string CreateByWorkflowTagName = "create-by-workflow";
    public WorkflowNameDto WorkflowName { get; set; }
}

public class WorkflowNameDto
{
    [XmlElement(Constants.WorkflowNameTagName)] // this is     public const string WorkflowNameTagName = "workflow-name";
    public string WorkflowName { get; set; }
}

The JSON looks like this in Swagger:

"workflowName": {
    "workflowName": "string"
}

Is there a way to have it just be  "workflowName": "string" to the user so something along these lines although this does not work:

[XmlElement(Constants.CreateByWorkflowTagName)] 
[XmlElement(Constants.WorkflowNameTagName)]
public string WorkflowName { get; set; }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 11 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 11 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros