I\'m given a xsd generated C# POCO object that I need to convert to xml. The expected payload however doesn\'t match the xsds I was given. Specifically, I need to omit the
I sometimes use RegEx or XML Linq
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string input =
"\n" +
"\n" +
"1.4 \n" +
" \n" +
"v" +
"WMSkuCap0180 \n" +
"\n" +
"EACH \n" +
"3 \n" +
" \n" +
"1 \n" +
" \n" +
" \n";
string pattern1 = @"<[^/][^:]+:";
string output = Regex.Replace(input, pattern1, "<");
string pattern2 = @"[^:]+:";
output = Regex.Replace(output, pattern2, "");
//using xml linq
XElement element = XElement.Parse(input);
foreach (var node in element.DescendantNodesAndSelf())
{
if (node.NodeType == XmlNodeType.Element)
{
((XElement)node).Name = ((XElement)node).Name.LocalName;
}
}
}
}
}