WeixiangYan/CodeTransOcean huggingface dataset:
Task: XML_Input







Python: import xml.dom.minidom

doc = 

doc = xml.dom.minidom.parseString(doc)

for i in doc.getElementsByTagName("Student"):
    print i.getAttribute("Name")





Ada: with Sax.Readers;
with Input_Sources.Strings;
with Unicode.CES.Utf8;
with My_Reader;

procedure Extract_Students is
   Sample_String : String :=
"<Students>" &
   "<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />" &
   "<Student Name=""Bob"" Gender=""M"" DateOfBirth=""1990-03-04"" />" &
   "<Student Name=""Chad"" Gender=""M"" DateOfBirth=""1991-05-06"" />" &
   "<Student Name=""Dave"" Gender=""M"" DateOfBirth=""1992-07-08"">" &
      "<Pet Type=""dog"" Name=""Rover"" />" &
   "</Student>" &
   "<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""&#x00C9;mily"" />" &
"</Students>";
   Reader : My_Reader.Reader;
   Input : Input_Sources.Strings.String_Input;
begin
   Input_Sources.Strings.Open (Sample_String, Unicode.CES.Utf8.Utf8_Encoding, Input);
   My_Reader.Parse (Reader, Input);
   Input_Sources.Strings.Close (Input);
end Extract_Students;
Task: XML_Input








VB: Option Explicit

Const strXml As String = "" & _
"<Students>" & _
    "<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />" & _
    "<Student Name=""Bob"" Gender=""M""  DateOfBirth=""1990-03-04"" />" & _
    "<Student Name=""Chad"" Gender=""M""  DateOfBirth=""1991-05-06"" />" & _
    "<Student Name=""Dave"" Gender=""M""  DateOfBirth=""1992-07-08"">" & _
        "<Pet Type=""dog"" Name=""Rover"" />" & _
    "</Student>" & _
    "<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""&#x00C9;mily"" />" & _
"</Students>"

Sub Main_Xml()
Dim MyXml As Object
Dim myNodes, myNode

    With CreateObject("MSXML2.DOMDocument")
        .LoadXML strXml
        Set myNodes = .getElementsByTagName("Student")
    End With
    If Not myNodes Is Nothing Then
        For Each myNode In myNodes
            Debug.Print myNode.getAttribute("Name")
        Next
    End If
    Set myNodes = Nothing
End Sub




Ada: with Sax.Readers;
with Input_Sources.Strings;
with Unicode.CES.Utf8;
with My_Reader;

procedure Extract_Students is
   Sample_String : String :=
"<Students>" &
   "<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />" &
   "<Student Name=""Bob"" Gender=""M"" DateOfBirth=""1990-03-04"" />" &
   "<Student Name=""Chad"" Gender=""M"" DateOfBirth=""1991-05-06"" />" &
   "<Student Name=""Dave"" Gender=""M"" DateOfBirth=""1992-07-08"">" &
      "<Pet Type=""dog"" Name=""Rover"" />" &
   "</Student>" &
   "<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""&#x00C9;mily"" />" &
"</Students>";
   Reader : My_Reader.Reader;
   Input : Input_Sources.Strings.String_Input;
begin
   Input_Sources.Strings.Open (Sample_String, Unicode.CES.Utf8.Utf8_Encoding, Input);
   My_Reader.Parse (Reader, Input);
   Input_Sources.Strings.Close (Input);
end Extract_Students;
Task: XML_Input

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

static void print_names(xmlNode *node)
{
  xmlNode *cur_node = NULL;
  for (cur_node = node; cur_node; cur_node = cur_node->next) {
    if (cur_node->type == XML_ELEMENT_NODE) {
      if ( strcmp(cur_node->name, "Student") == 0 ) {
	xmlAttr *prop = NULL;
	if ( (prop = xmlHasProp(cur_node, "Name")) != NULL ) {
	  printf("%s\n", prop->children->content);
	  
	}
      }
    }
    print_names(cur_node->children);
  }
}

const char *buffer =
  "<Students>\n"
  "  <Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"
  "  <Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"
  "  <Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"
  "  <Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"
  "    <Pet Type=\"dog\" Name=\"Rover\" />\n"
  "  </Student>\n"
  "  <Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"
  "</Students>\n";

int main()
{
  xmlDoc *doc = NULL;
  xmlNode *root = NULL;

  doc = xmlReadMemory(buffer, strlen(buffer), NULL, NULL, 0);
  if ( doc != NULL ) {
    root = xmlDocGetRootElement(doc);
    print_names(root);
    xmlFreeDoc(doc);
  }
  xmlCleanupParser();
  return 0;
}
Task: XML_Input



C#: class Program
{
    static void Main(string[] args)
    {   
        XDocument xmlDoc = XDocument.Load("XMLFile1.xml");
        var query = from p in xmlDoc.Descendants("Student")
                    select p.Attribute("Name");

        foreach (var item in query)
        {
            Console.WriteLine(item.Value);
        }
        Console.ReadLine();
    }  
}
Task: XML_Input


C++: 
#include <iostream>

#include <QDomDocument>
#include <QObject>

int main() {
    QDomDocument doc;

    doc.setContent(
       QObject::tr(
          "<Students>\n"
          "<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"
          "<Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"
          "<Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"
          "<Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"
          "<Pet Type=\"dog\" Name=\"Rover\" />\n"
          "</Student>\n"
          "<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"
          "</Students>"));
    
    QDomElement n = doc.documentElement().firstChildElement("Student");
    while(!n.isNull()) {
        std::cout << qPrintable(n.attribute("Name")) << std::endl;
        n = n.nextSiblingElement();
    }
    return 0;
}
Task: XML_Input





Java: import java.io.IOException;
import java.io.StringReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;

public class StudentHandler extends DefaultHandler {
  public static void main(String[] args)throws Exception{
    String xml = "<Students>\n"+
    "<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"+
    "<Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"+
    "<Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"+
    "<Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"+
    "  <Pet Type=\"dog\" Name=\"Rover\" />\n"+
    "</Student>\n"+
    "<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"+
    "</Students>";
    StudentHandler handler = new StudentHandler();
    handler.parse(new InputSource(new StringReader(xml)));
  }

  public void parse(InputSource src) throws SAXException, IOException {
		XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(this);
    parser.parse(src);
  }

  @Override
  public void characters(char[] ch, int start, int length) throws SAXException {
    
    
    super.characters(ch, start, length);
  }

  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    
    
    super.endElement(uri, localName, qName);
  }

  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if(qName.equals("Student")){
      System.out.println(attributes.getValue("Name"));
    }
  }
}
Task: XML_Input







Python: import xml.dom.minidom

doc = 

doc = xml.dom.minidom.parseString(doc)

for i in doc.getElementsByTagName("Student"):
    print i.getAttribute("Name")
Task: XML_Input








VB: Data 32, 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174, 170, 32, 169, 238
Data 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168
Data 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216
Data 209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225
Data 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139
Data 208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231, 152

Dim Shared As Integer numCodes, initCode
initCode = 160
numCodes = 255 - initCode + 1

Dim Shared As Integer codes(numCodes)
For i As Integer = 0 To numCodes - 1 : Read codes(i) 
Next i

Function codeConversion(charcode As Integer, tocode As Integer = False) As Integer
    If tocode Then
        For i As Integer = 0 To numCodes - 1
            If codes(i) = charcode Then Return i + initCode
        Next i
    Else
        Return codes(charcode - initCode)
    End If
End Function

Function convASCII(nombre As String, mark As String) As String
    Dim As Integer p, c, lm = Len(mark)
    
    Do
        p = Instr(p, nombre, mark)
        If p = 0 Then Exit Do
        c = Valint(Mid(nombre, p + lm, 4))
        c = codeConversion(c)
        nombre = Left(nombre, p-1) + Chr(c) + Right(nombre, Len(nombre) - (p + lm + 4))
        p += 1
    Loop
    Return nombre
End Function

Dim As String strXml =  "<Students>"
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "    <Pet Type=\
strXml += "  </Student>"
strXml += "  <Student DateOfBirth=\
strXml += "</Students>"

Dim As String tag1 = "<Student"
Dim As String tag2 = "Name=\
Dim As Integer ltag = Len(tag2), p = 1, p2

Do
    p = Instr(p, strXml, tag1)
    If p = 0 Then Exit Do
    p = Instr(p, strXml, tag2)
    p += ltag
    p2 = Instr(p, strXml, "\
    nombre = convASCII(Mid(strXml, p, p2 - p), "&#x")
    Print nombre
Loop

Sleep
Task: XML_Input




Go: package main

import (
    "encoding/xml"
    "fmt"
)

const XML_Data = `
<Students>
   <Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
   <Student Name="Bob" Gender="M"  DateOfBirth="1990-03-04" />
   <Student Name="Chad" Gender="M"  DateOfBirth="1991-05-06" />
   <Student Name="Dave" Gender="M"  DateOfBirth="1992-07-08">
      <Pet Type="dog" Name="Rover" />
   </Student>
   <Student DateOfBirth="1993-09-10" Gender="F" Name="&#x00C9;mily" />
</Students>
`

type Students struct {
    Student []Student
}

type Student struct {
    Name string `xml:",attr"`
    
    
    
}

type Pet struct {
    Type string `xml:",attr"`
    Name string `xml:",attr"`
}





func main() {
    var data Students
    err := xml.Unmarshal([]byte(XML_Data), &data)
    if err != nil {
        fmt.Println(err)
        return
    }
    for _, s := range data.Student {
        fmt.Println(s.Name)
    }
}
Task: XML_Input



C#: class Program
{
    static void Main(string[] args)
    {   
        XDocument xmlDoc = XDocument.Load("XMLFile1.xml");
        var query = from p in xmlDoc.Descendants("Student")
                    select p.Attribute("Name");

        foreach (var item in query)
        {
            Console.WriteLine(item.Value);
        }
        Console.ReadLine();
    }  
}








Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input


C++: 
#include <iostream>

#include <QDomDocument>
#include <QObject>

int main() {
    QDomDocument doc;

    doc.setContent(
       QObject::tr(
          "<Students>\n"
          "<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"
          "<Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"
          "<Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"
          "<Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"
          "<Pet Type=\"dog\" Name=\"Rover\" />\n"
          "</Student>\n"
          "<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"
          "</Students>"));
    
    QDomElement n = doc.documentElement().firstChildElement("Student");
    while(!n.isNull()) {
        std::cout << qPrintable(n.attribute("Name")) << std::endl;
        n = n.nextSiblingElement();
    }
    return 0;
}









Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input

C: #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

static void print_names(xmlNode *node)
{
  xmlNode *cur_node = NULL;
  for (cur_node = node; cur_node; cur_node = cur_node->next) {
    if (cur_node->type == XML_ELEMENT_NODE) {
      if ( strcmp(cur_node->name, "Student") == 0 ) {
	xmlAttr *prop = NULL;
	if ( (prop = xmlHasProp(cur_node, "Name")) != NULL ) {
	  printf("%s\n", prop->children->content);
	  
	}
      }
    }
    print_names(cur_node->children);
  }
}

const char *buffer =
  "<Students>\n"
  "  <Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"
  "  <Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"
  "  <Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"
  "  <Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"
  "    <Pet Type=\"dog\" Name=\"Rover\" />\n"
  "  </Student>\n"
  "  <Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"
  "</Students>\n";

int main()
{
  xmlDoc *doc = NULL;
  xmlNode *root = NULL;

  doc = xmlReadMemory(buffer, strlen(buffer), NULL, NULL, 0);
  if ( doc != NULL ) {
    root = xmlDocGetRootElement(doc);
    print_names(root);
    xmlFreeDoc(doc);
  }
  xmlCleanupParser();
  return 0;
}










Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input





Java: import java.io.IOException;
import java.io.StringReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.helpers.XMLReaderFactory;

public class StudentHandler extends DefaultHandler {
  public static void main(String[] args)throws Exception{
    String xml = "<Students>\n"+
    "<Student Name=\"April\" Gender=\"F\" DateOfBirth=\"1989-01-02\" />\n"+
    "<Student Name=\"Bob\" Gender=\"M\"  DateOfBirth=\"1990-03-04\" />\n"+
    "<Student Name=\"Chad\" Gender=\"M\"  DateOfBirth=\"1991-05-06\" />\n"+
    "<Student Name=\"Dave\" Gender=\"M\"  DateOfBirth=\"1992-07-08\">\n"+
    "  <Pet Type=\"dog\" Name=\"Rover\" />\n"+
    "</Student>\n"+
    "<Student DateOfBirth=\"1993-09-10\" Gender=\"F\" Name=\"&#x00C9;mily\" />\n"+
    "</Students>";
    StudentHandler handler = new StudentHandler();
    handler.parse(new InputSource(new StringReader(xml)));
  }

  public void parse(InputSource src) throws SAXException, IOException {
		XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(this);
    parser.parse(src);
  }

  @Override
  public void characters(char[] ch, int start, int length) throws SAXException {
    
    
    super.characters(ch, start, length);
  }

  @Override
  public void endElement(String uri, String localName, String qName) throws SAXException {
    
    
    super.endElement(uri, localName, qName);
  }

  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if(qName.equals("Student")){
      System.out.println(attributes.getValue("Name"));
    }
  }
}






Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input







Python: import xml.dom.minidom

doc = 

doc = xml.dom.minidom.parseString(doc)

for i in doc.getElementsByTagName("Student"):
    print i.getAttribute("Name")




Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input








VB: Data 32, 173, 189, 156, 207, 190, 221, 245, 249, 184, 166, 174, 170, 32, 169, 238
Data 248, 241, 253, 252, 239, 230, 244, 250, 247, 251, 167, 175, 172, 171, 243, 168
Data 183, 181, 182, 199, 142, 143, 146, 128, 212, 144, 210, 211, 222, 214, 215, 216
Data 209, 165, 227, 224, 226, 229, 153, 158, 157, 235, 233, 234, 154, 237, 232, 225
Data 133, 160, 131, 198, 132, 134, 145, 135, 138, 130, 136, 137, 141, 161, 140, 139
Data 208, 164, 149, 162, 147, 228, 148, 246, 155, 151, 163, 150, 129, 236, 231, 152

Dim Shared As Integer numCodes, initCode
initCode = 160
numCodes = 255 - initCode + 1

Dim Shared As Integer codes(numCodes)
For i As Integer = 0 To numCodes - 1 : Read codes(i) 
Next i

Function codeConversion(charcode As Integer, tocode As Integer = False) As Integer
    If tocode Then
        For i As Integer = 0 To numCodes - 1
            If codes(i) = charcode Then Return i + initCode
        Next i
    Else
        Return codes(charcode - initCode)
    End If
End Function

Function convASCII(nombre As String, mark As String) As String
    Dim As Integer p, c, lm = Len(mark)
    
    Do
        p = Instr(p, nombre, mark)
        If p = 0 Then Exit Do
        c = Valint(Mid(nombre, p + lm, 4))
        c = codeConversion(c)
        nombre = Left(nombre, p-1) + Chr(c) + Right(nombre, Len(nombre) - (p + lm + 4))
        p += 1
    Loop
    Return nombre
End Function

Dim As String strXml =  "<Students>"
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "  <Student Name=\
strXml += "    <Pet Type=\
strXml += "  </Student>"
strXml += "  <Student DateOfBirth=\
strXml += "</Students>"

Dim As String tag1 = "<Student"
Dim As String tag2 = "Name=\
Dim As Integer ltag = Len(tag2), p = 1, p2

Do
    p = Instr(p, strXml, tag1)
    If p = 0 Then Exit Do
    p = Instr(p, strXml, tag2)
    p += ltag
    p2 = Instr(p, strXml, "\
    nombre = convASCII(Mid(strXml, p, p2 - p), "&#x")
    Print nombre
Loop

Sleep



Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input






PHP: <?php
$data = '<Students>
  <Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
  <Student Name="Bob" Gender="M"  DateOfBirth="1990-03-04" />
  <Student Name="Chad" Gender="M"  DateOfBirth="1991-05-06" />
  <Student Name="Dave" Gender="M"  DateOfBirth="1992-07-08">
    <Pet Type="dog" Name="Rover" />
  </Student>
  <Student DateOfBirth="1993-09-10" Gender="F" Name="&#x00C9;mily" />
</Students>';
$xml = new XMLReader();
$xml->xml( $data );
while ( $xml->read() )
	if ( XMLREADER::ELEMENT == $xml->nodeType && $xml->localName == 'Student' )
		echo $xml->getAttribute('Name') . "\n";
?>





Fortran: program tixi_rosetta
  use tixi
  implicit none
  integer :: i
  character (len=100) :: xml_file_name 
  integer :: handle
  integer :: error	
  character(len=100) :: name, xml_attr
  xml_file_name = 'rosetta.xml'

  call tixi_open_document( xml_file_name, handle, error )
  i = 1
  do 
      xml_attr = '/Students/Student['//int2char(i)//']'
      call tixi_get_text_attribute( handle, xml_attr,'Name', name, error )      
      if(error /= 0) exit
      write(*,*) name
      i = i + 1
  enddo

  call tixi_close_document( handle, error )

  contains

  function int2char(i) result(res)
    character(:),allocatable :: res
    integer,intent(in) :: i
    character(range(i)+2) :: tmp
    write(tmp,'(i0)') i
    res = trim(tmp)
  end function int2char

end program tixi_rosetta
Task: XML_Input






PHP: <?php
$data = '<Students>
  <Student Name="April" Gender="F" DateOfBirth="1989-01-02" />
  <Student Name="Bob" Gender="M"  DateOfBirth="1990-03-04" />
  <Student Name="Chad" Gender="M"  DateOfBirth="1991-05-06" />
  <Student Name="Dave" Gender="M"  DateOfBirth="1992-07-08">
    <Pet Type="dog" Name="Rover" />
  </Student>
  <Student DateOfBirth="1993-09-10" Gender="F" Name="&#x00C9;mily" />
</Students>';
$xml = new XMLReader();
$xml->xml( $data );
while ( $xml->read() )
	if ( XMLREADER::ELEMENT == $xml->nodeType && $xml->localName == 'Student' )
		echo $xml->getAttribute('Name') . "\n";
?>