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); }
private void procesarContexto(XmlElement elemento) { IContexto contexto = new Contexto(); contexto.Id = elemento.GetAttribute("id"); foreach (XmlElement estructura in elemento.ChildNodes) { string[] s = estructura.Name.Split(':'); string e = s[s.Length - 1].ToLower(); if (e.Equals("entity")) { XmlNode identificador = estructura.FirstChild; IIdentificadorContexto contextoIdentificador = contexto.Identificador; contextoIdentificador.Descripcion = identificador.FirstChild.Value; contextoIdentificador.URI = identificador.Attributes[0].Value; //extraccion de segmentos XmlNode segmentos = identificador.NextSibling; if (segmentos != null) { XmlElement segmentos = contexto.Segmentos; foreach (XmlElement segmento in segmentos.ChildNodes) { segmentos.Add(segmento); } } } else if (e.Equals("period")) { XmlNode primerHijo = estructura.FirstChild; string elem = primerHijo.Name.ToLower(); if (elem.Equals("startdate")) { IPeriodoInicioFin periodo = new PeriodoInicioFin(primerHijo.FirstChild.Value, primerHijo.NextSibling.FirstChild.Value); contexto.Periodo = periodo; } else { IPeriodoInstante periodo = new PeriodoInstante(primerHijo.FirstChild.Value); contexto.Periodo = periodo; } } //else if (e.Equals("scenario")) //{ //} } _contextos.Add(contexto.Id, contexto); //throw new Exception("The method or operation is not implemented."); }
public override VisualElement Render() { base.Render(); XmlElement.Add(m_menuPage.XmlElement); XmlElement.Add(m_gamePage.XmlElement); m_gamePage.XmlElement.AddToClassList("hide"); return(XmlElement); }
void Serialize(IList nodeCollection, XmlElement parent) //, ArrayList parent) { foreach (NDOTreeNode trn in nodeCollection) { #if Soap ArrayList al = new ArrayList(); parent.Add(new ValuePair(trn, al)); #endif XmlElement el = parent.OwnerDocument.CreateElement("NDOTreeNode"); parent.AppendChild(el); trn.ToXml(el); Serialize(trn.Nodes, el); } }
public void AddXmlTest1() { string expected = "<Root><Item1>1</Item1><Item2 id=\"test\">2</Item2><Item3>3</Item3><Item4><SubItem1>s1</SubItem1><SubItem2>s2</SubItem2></Item4></Root>"; XmlDocument xmlDoc = new XmlDocument(); XmlElement elem = xmlDoc.CreateElement("Root"); elem.Add("Item1", "1") .Add("Item2", new[] { "id", "test" }, "2") .Add("Item3", "3") .Add("Item4", xmlDoc.NewElement("SubItem1", "s1"), xmlDoc.NewElement("SubItem2", "s2")); xmlDoc.AppendChild(elem); Assert.AreEqual(expected, xmlDoc.InnerXml); }
private static void GetSource(IdName name, XmlElement element) { if (sources.ContainsKey(name)) { return; } foreach (string key in sourceDic.Keys) { XmlElement e = element.GetChild(key); if (e != null) { object o = sourceDic[key](e); element.Add <object>(o, sources); return; } } }
static object GetFloatArray(XmlElement element) { double[] x = element.ToDoubleArray(); element.Add <double[]>(x, arrays); return(x); }
private static void GetVetrices(IdName name, XmlElement element) { double[] x = element.FindSource <double[]>(); element.Add <object>(x, sources); element.Add <double[]>(x, arrays); }