snippets / xml

All snippets tagged xml (7)

  1. loop through XML document using XPATH

    .

    1 XmlDocument doc = new XmlDocument();
    2 doc.Load(@"test.xml");
    3 XmlElement root = doc.DocumentElement;
    4 foreach (XmlNode @daten in doc.SelectNodes("/workload/actualWorkload/*"))
    5 {
    6 Console.WriteLine(@daten.Attributes["id"].InnerText + ": " + @daten.InnerText);
    7 }
    Posted by qrist0ph to c# xml xpath ... saved by 1 person ... 0 comments ... 5 months
  2. Set Comos Workload XML

    .

    1  System.Collections.ICollection col = this.GetSpecificationCollection("RES.ADDR");
    2 foreach (IComosDSpecification e in col)
    3 {
    4 e.XMLString = s;
    5 //WrapperDebug.WriteLine("Arbeitszeit " + e.XMLString);
    6 }
    Posted by qrist0ph to c# comos xml ... saved by 1 person ... 0 comments ... 5 months, 1 week
  3. XML processing in C#

    dd

     1  static void Csharp_HelloWorld_XML()
    2 {
    3 XmlDocument doc = new XmlDocument();
    4 XmlNode myRoot;
    5 XmlAttribute myAttribute;
    6
    7
    8 myRoot = doc.CreateElement("HelloXMLWorld");
    9 doc.AppendChild(myRoot);
    10 myAttribute = doc.CreateAttribute("Attribute1");
    11 myAttribute.InnerText = "AttributeText1";
    12 myRoot.Attributes.Append(myAttribute);
    13 //doc.Save(@"c:\helloxmlworld.xml");
    14 Console.WriteLine(doc.OuterXml);
    15 }
    Posted by qrist0ph to c# xml ... saved by 1 person ... 0 comments ... 5 months, 1 week
  4. simple xml serializer

    simple xml serializer that convert a python object in xml file.

     1 def serialize_xml(d):
    2 # simple serializer
    3 if not isinstance(d, (dict,list,tuple)):
    4 raise TypeError("Expected a dict here")
    5 yield "\r\n"
    6 if isinstance(d, dict):
    7 for k,v in d.items():
    8 if isinstance(v, (dict,list,tuple)):
    9 v = "".join(serialize_xml(v))
    10 yield "<%(key)s>%(value)s</%(key)s>\r\n" % {
    11 'key':k,
    12 'value':v
    13 }
    14 elif isinstance(d, (tuple, list)):
    15 for v in d:
    16 if isinstance(v, (dict,list,tuple)):
    17 v = serialize_xml(v)
    18 yield "<value>%s</value>\r\n" % v
    Posted by benoitc to python xml serializer ... saved by 2 persons ... 0 comments ... 5 months, 1 week
  5. loader une image d'un fichier xml en AS3

    bâtir l'URL du URLRequest pour prendre le fichier xml.

     1 xmlLoader.load(new URLRequest("xmlSpecs/"+ nomSerie +"/"+nomModele+"_"+ lang +".xml"));
    2 // lorsque le fichier xml est fini de loader, on part la fonction xmlLoaded
    3 xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    4
    5 function xmlLoaded(event:Event):void
    6 {
    7 var nombreImages:int = specsConteneur.numChildren;
    8 for(var i:int=0; i<nombreImages; i++){
    9 specsConteneur.removeChildAt(0);
    10 }
    11 xml = XML(event.target.data); // le fichier xml
    12 xmlList = xml.children(); // la liste d'items dans le fichier xml
    13 //trace('xmlLoaded');
    14 imageLoader = new Loader(); // on crée une variable Loader
    15 imageLoader.load(new URLRequest(xmlList[0].attribute("source"))); // on load ce qu'il y a dans l'attribut "thumb" du fichier xml
    16 imageLoader.x = 241; // on dit sa position x dans les thumbnails
    17 imageLoader.y = 63; // on dit sa position y dans les thumbnails
    18 specsConteneur.addChild(imageLoader); // on affiche imageLoader dans la liste d'affichage
    19
    20 }
    Posted by juliend2 to none xml as3 preload ... saved by 1 person ... 0 comments ... 5 months, 2 weeks
  6. Read XML file and Iterate through Rows

    You can call this function on Page load like this: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ReadXMLFile() End Sub

     1 Function ReadXMLFile()        
    2 Dim strBuilder As StringBuilder = New StringBuilder() 'Read XML File
    3 Dim ds As New DataSet()
    4 ds.ReadXml("C:\Website\XMLMadness\App_Data\USA.xml") 'Iterate through the tables in DataSet.
    5 Dim dt As DataTable
    6 dt = ds.Tables(0) 'Iterate through the rows in a table.
    7 Dim n As Integer
    8 For n = 0 To dt.Rows.Count - 1 'Do stuf to your data here.
    9 'strBuilder.Append(dt.Rows(n)(1) & vbCrLf)
    10 strBuilder.Append(dt.Rows(n)(1) & "<br />")
    11 'strBuilder.Append(Chr(34) & dt.Rows(n)(0) & Chr(34) & "<br />")
    12 'Get a different column
    13 'strBuilder.Append(Chr(34) & dt.Rows(n)(1) & Chr(34) & "<br />")
    14 Next
    15 Literal1.Text = strBuilder.ToString
    16 Return strBuilder.ToString()
    17 End Function
  7. Ouverture et Enregistrement XML

    Ouverture et Enregistrement XML en Python

     1 import xml.dom
    2 import xml.dom.ext.reader.Sax2
    3 import xml.dom.ext
    4
    5 # Ouverture du fichier XML
    6 f = open('fichier.xml'), 'r')
    7 reader = xml.dom.ext.reader.Sax2.Reader()
    8 dom = reader.fromStream(f)
    9
    10 # Manipulation du DOM
    11 # ...
    12
    13 # Enregistrement
    14 xml.dom.ext.Print(dom, open('fichier.xml', 'w'))
    15 # Enregistrement indenté
    16 xml.dom.ext.PrettyPrint(dom, open('fichier.xml', 'w'))
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...