void AttributesToXml(XmbFile xmb, XmlDocument doc, XmlElement e) { if (Attributes.Count > 0) { foreach (var kv in Attributes) { string k = xmb.ToString(kv.Key); string v = xmb.ToString(kv.Value); var attr = doc.CreateAttribute(k); attr.Value = v; // #HACK avoids exceptions like: // "The prefix '' cannot be redefined from '' to 'http://www.w3.org/2000/09/xmldsig#' within the same start element tag." // for XML files that weren't meant for the game but were transformed to XMB anyway if (string.CompareOrdinal(k, "xmlns") == 0) { var comment = doc.CreateComment(attr.OuterXml); e.AppendChild(comment); continue; } e.Attributes.Append(attr); } } }
void InnerTextToXml(XmbFile xmb, XmlDocument doc, XmlElement e) { if (!InnerTextVariant.IsEmpty) { var text = doc.CreateTextNode(xmb.ToString(InnerTextVariant)); e.AppendChild(text); } }
public XmlElement ToXml(XmbFile xmb, XmlDocument doc, XmlElement root) { var e = doc.CreateElement(xmb.ToString(NameVariant)); if (root != null) { root.AppendChild(e); } AttributesToXml(xmb, doc, e); ChildrenToXml(xmb, doc, e); InnerTextToXml(xmb, doc, e); return(e); }