troubleshooting Question

C# code does not output the XML format i want.

Avatar of GeneBe
GeneBeFlag for United States of America asked on
10 Comments1 Solution83 ViewsLast Modified:
My C# code does not output the XML format i want.
Here's the code:

[WebMethod(Description = "GetAddressTest")]
[return: XmlRoot(ElementName = "AddressTest")]
public string GetAddressTest(string memberNbr)
    XNamespace defaultNamespace = XNamespace.Get("");
    XElement addressInfo = new XElement("AddressDetail");
    IList<string> addressList = new List<string> { "101 state st", "201 exit st", "301 entrance st" };
    var i = 0;
    foreach (string item in addressList)
        addressInfo.SetElementValue("Address", item[i]);
    return addressInfo.ToString();

Open in new window

here's the output format i want:

<?xml version="1.0" encoding="UTF-8"?>
<MemberSpansTest xmlns="">
		<Address>101 state st</Address> 
		<Address>201 exit st</Address> 
		<Address>301 entrance st</Address> 

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 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 10 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