xml-como criar/executar um ficheiro XML

Alguém me pode aconselhar sobre o que preciso de fazer .ficheiro xml? Posso criá-lo no bloco de notas? e guarda - o com um.extensão xml em seguida, faça duplo-click no ficheiro enquanto estiver no Windows ou Faça Preciso de um editor especial?

Eu tenho uma aplicação java e quero usar a tecnologia Jave Web Start que requer um ficheiro da JNLP da minha .jar file.

Obrigado.
 2
xml
Author: pyvi, 2011-02-07

3 answers

Claro que pode correr um ficheiro xml. Para ser exato: você pode executar um arquivo xsl, que é um tipo especial de xml com código xslt, mas também texto puro, assim como outro código fonte. O interpretador no qual o script xslt é executado é o seu navegador.
Então você precisa de dois arquivos:

A. um ficheiro xml contendo os dados e a informação que o programa deve utilizar (nomeie-o "teste.xml"):

<?xml version="1.0" encoding="utf-8"?>  
<?xml-stylesheet type="text/xsl" href="test.xsl"?>  
<root>data</root>

B. Um ficheiro xsl que contém o programa (nomeie-o "teste.xsl"):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">  
    <html>
      <head>
        <title>Show XML</title>
      <head>
      <body>
        <xsl:value-of select="."/>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Se o seu SO não saber que programa usar ao abrir o arquivo xml, diga-lhe que é o navegador. E sim, você só precisa de qualquer editor como notepad e qualquer navegador como firefox ou ie. Usar um que sabe xml é mais convincente, mas notepad e ie já são um ambiente de desenvolvimento completo - standanlone, sem precisar de qualquer java, então eu não sei por que você mencioná-lo.

 1
Author: Andreas, 2011-08-20 09:28:20

Esta é uma inserção simples num ficheiro xml que utiliza o C#

{ invoque o método primeiro..............

   public void InvokeKey()
    {
        DSXml.ReadXml(@"c:\users\general\documents\visual studio 2010\Projects\xml_practice\xml_practice\todolist.xml");

        DataColumn[] ID = new DataColumn[1];

        ID[0] = DSXml.Tables[0].Columns[0];

        DSXml.Tables[0].PrimaryKey = ID;
    }

DataSet DsXml = novo conjunto de dados (); DataRow DrXML;

    string Date = Convert.ToString(System.DateTime.Now.ToString("d"));
    string Time = Convert.ToString(System.DateTime.Now.ToString("hh:mm:ss"));

    int ID;




    InvokeKey();
            DRXML = DSXml.Tables[0].Rows.Find(ID);

    DsXml.WriteXml(@"path");

        DrXML = DsXml.Tables[0].NewRow();

        DrXML[0] = ID;
        DrXML[0] = ID;
        DrXML[0] = ID;
        DrXML[0] = ID;
        DrXML[0] = ID;
        DrXML[0] = ID;

        DsXml.Tables[0].Rows.Add(DrXML);

        DsXml.WriteXml(@"path");

Dt = Relatório.Sub-projectos de carga ();

        Excel.Application xlApp = new Excel.Application(); // open app
        xlApp.Visible = true;

        Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(1); //open workbook
        Excel.Worksheet xlSheet = (Excel.Worksheet)xlWorkBook.Worksheets[1]; //open worksheet


        xlSheet.Cells.Rows.Columns.AutoFit(); 

        string strTempVariable = dt.Rows[0][0].ToString();   //temporary variable

        xlSheet.Cells[4, 1] = dt.Rows[0][0].ToString();

        xlSheet.Cells[1, 1] = "Employees group header";

        for (int count = 0; count < dt.Columns.Count;count++ )
        {
            xlSheet.Cells[3, count+1] = dt.Columns[count].ColumnName;// prints column names
        }
        int group=0;
        int total=0;
        int intRow = 5;//manages xlsheet

        for (int counter = 0; counter < dt.Rows.Count;counter++ )
        {
            if (strTempVariable == dt.Rows[counter]["City"].ToString())
            {
                xlSheet.Cells[intRow, 2] = dt.Rows[counter][1];
                xlSheet.Cells[intRow, 3] = dt.Rows[counter][2];
                xlSheet.Cells[intRow, 4] = dt.Rows[counter][3];
                xlSheet.Cells[intRow, 5] = dt.Rows[counter][4];
                group++;
                total++;
                intRow++;
            }
            else
            {
                xlSheet.Cells[intRow, 4] = "group name  " + strTempVariable + "  " + group.ToString();

                strTempVariable = dt.Rows[counter][0].ToString();
                intRow++;
                xlSheet.Cells[intRow, 1] = strTempVariable;
                intRow++;
                counter--;
                group = 0;
            }

        }
          intRow++;
       xlSheet.Cells[intRow, 4] = "group name  " + strTempVariable + "  "+group.ToString();  
             intRow++;
        xlSheet.Cells[intRow, 4] = "GrandTotal  " + "  "+total.ToString();



        xlWorkBook.Close(true, "GROUP REPORT", 0);//The name of the worksheet

        xlApp.Quit();

       // return "Report Successfully";

    }

Calendário do relatório público de strings() {

        DataTier.clsDataAccess Data = new DataTier.clsDataAccess();

        int intCount = 0;
        int intCount2 = 5;


        Data.sqlcon.Close();
        Data.sqlcon.Open();


        Data.sqlAdpter = new SqlDataAdapter("SELECT * FROM USERS ORDER BY password",Data.sqlcon);
        DataTable ReportDt = new DataTable("Report");

        Data.sqlAdpter.Fill(ReportDt);
        Data.sqlcon.Close();

       string strMsg = "";

        Excel.Application xlApp = new Excel.Application();
        xlApp.Visible = true;



        Excel.Workbook xlWorkbook = xlApp.Workbooks.Add(1);
        Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];


        // Setting cell values
        ((Excel.Range)xlWorksheet.Cells[1, "A"]).Value2 = "Report - USERS "; //main heading

        ((Excel.Range)xlWorksheet.Cells[3, "A"]).Value2 = "USERNAME"; //field headings
        ((Excel.Range)xlWorksheet.Cells[3, "B"]).Value2 = "PASSWORD";
       // ((Excel.Range)xlWorksheet.Cells[3, "C"]).Value2 = "MARK";


        for (intCount = 0; intCount < ReportDt.Rows.Count; intCount++)
        {
            xlWorksheet.Cells[intCount2, "A"] = ReportDt.Rows[intCount][0];
            xlWorksheet.Cells[intCount2, "B"] = ReportDt.Rows[intCount][1];
           // xlWorksheet.Cells[intCount2, "C"] = ReportDt.Rows[intCount][2];


            intCount2++;
        }
        xlWorksheet.Cells.Columns.AutoFit();
        strMsg = "report successful";
        return strMsg;
 1
Author: user3062716, 2013-12-04 21:22:13

Você não precisa de um editor especial, mas isso pode ajudar muito durante a edição.

Não pode executar um ficheiro xml. Mas você pode executar um programa que usa o arquivo xml.

Para "executar" o ficheiro xml, você provavelmente precisa de algo como a seguinte declaração:

java -jar yourFile.jar packageOfMainMethod.ClassWithMainMethod yourXML.xml
Mas isso depende do programa que você tentar executar.
 0
Author: Thijs Wouters, 2011-02-07 11:49:05