Beispiel #1
0
        private XmlElement Add(string name, string value, IDictionary<string, string> attributes)
        {
            if (Value != null)
                throw new InvalidOperationException("XML Element " + Name + " has a text value: it cannot contain child elements");

            var child = new XmlElement(this) { Name = name, Value = value, Attributes = attributes };
            Children.Add(child);
            return child;
        }
Beispiel #2
0
		public XmlElement GenerateXML()
		{
			var post = new XmlElement { Name = "item" };

			post.Add("title").CData(Title).Up()
				.Add("description", Description).Up()
				.Add("pubDate", Date.ToString()).Up()
				.Add("content:encoded").CData(Content).Up()
				.Add("wp:post_id", Id).Up()
				.Add("wp:post_date", Date.ToString()).Up()
				.Add("wp:post_date_gmt", Date.ToUniversalTime().ToString()).Up()
				.Add("wp:post_type", "post").Up()
				.Add("wp:status", Status).Up();

			foreach (var tag in Tags)
				post.Add("category", new { nicename = tag.Slug, domain = "post_tag" })
					.CData(tag.Name);

			foreach (var cat in Categories)
				post.Add("category", new { nicename = cat.NiceName, domain = "category"})
					.CData(cat.Name);

			return post;
		}
Beispiel #3
0
 protected AbstractXmlElement(XmlElement parent = null)
 {
     Parent = parent;
 }
Beispiel #4
0
 public XmlElement(XmlElement parent = null)
     : base(parent)
 {
     Children = new List<IXmlElement>();
     Attributes = new Dictionary<string, string>();
 }
Beispiel #5
0
 public CDataElement(XmlElement parent = null)
     : base(parent)
 {
 }
Beispiel #6
0
 private static string GetAttributes(XmlElement e)
 {
     return e.Attributes.Aggregate(" ", (current, attr) => current + (attr.Key + "=\"" + attr.Value + "\" "));
 }
Beispiel #7
0
        public XmlElement Begin(string rootElementName)
        {
            RootElement = new XmlElement { Name = rootElementName };

            return RootElement;
        }
Beispiel #8
0
        private string GetAttributes(XmlElement e)
        {
            string s = " ";

            foreach (var attr in e.Attributes)
                s += attr.Key + "=\"" + attr.Value + "\" ";

            return s;
        }
 public AbstractXmlElement(XmlElement parent = null)
 {
     Parent = parent;
 }