Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="array">
- <entity>
- <id xsi:type="integer">1</id>
- <name>Foo</name>
- <parent-id xsi:type="integer" xsi:nil="true"/>
- public static void FixNilAttributeName(this XmlNode @this)
- {
- XmlAttribute nilAttribute = @this.Attributes["nil"];
- if (nilAttribute == null)
- {
- return;
- }
- XmlAttribute newNil = @this.OwnerDocument.CreateAttribute("xsi", "nil", "http://www.w3.org/2001/XMLSchema-instance");
- newNil.Value = nilAttribute.Value;
- @this.Attributes.Remove(nilAttribute);
- @this.Attributes.Append(newNil);
- }
- xmlStr = Regex.Replace(xmlStr, "nil="true"", "xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"");
Add Comment
Please, Sign In to add comment