Пример #1
0
            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);
                    }
                }
            }
Пример #2
0
 void InnerTextToXml(XmbFile xmb, XmlDocument doc, XmlElement e)
 {
     if (!InnerTextVariant.IsEmpty)
     {
         var text = doc.CreateTextNode(xmb.ToString(InnerTextVariant));
         e.AppendChild(text);
     }
 }
Пример #3
0
            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);
            }