Exemplo n.º 1
0
    public static EditorXmlNode ParseDocumentProfiling(string xml, EditorXmlNodeType ignore)
    {
        EditorXmlNode document = null;

        //DateTime start = DateTime.Now;

        document = EditorXmlNode.ParseDocument(xml, ignore);

        //DateTime end = DateTime.Now;
        //TimeSpan span = end - start;

        //say ("parsing xml string to xml document: " + span.TotalSeconds + " sec");

        return(document);
    }
Exemplo n.º 2
0
    // -------------------------------------------------------------------------------------------------------------
    private void Initialize(string xmlfilename, bool forcenew)
    {
        #if !UNITY_WEBPLAYER
        mXmlFilename = EDITOR_STATE_FOLDER + "/" + xmlfilename;

        if (!Directory.Exists(EDITOR_STATE_FOLDER))
        {
            Directory.CreateDirectory(EDITOR_STATE_FOLDER);
        }

        if (forcenew)
        {
            File.CreateText(mXmlFilename).Close();
        }
        else if (!File.Exists(mXmlFilename))
        {
            Debug.LogWarning("File '" + xmlfilename + "' not found under " + EDITOR_STATE_FOLDER + " folder, creating a new one.");

            File.CreateText(mXmlFilename).Close();
        }

        mXmlFileContent = File.ReadAllText(mXmlFilename);

        EditorXmlNode file    = EditorXmlNode.ParseDocument(mXmlFileContent, EditorXmlNodeType.DATA);
        EditorXmlNode records = file.GetChildByName("records");

        mRecords = new Dictionary <string, string>();

        if (records != null)
        {
            foreach (EditorXmlNode record in records.GetChildrenByName("record"))
            {
                mRecords.Add(record.GetAttribute("name").content, record.GetAttribute("value").content);
            }
        }
        #endif
    }
Exemplo n.º 3
0
 public static EditorXmlNode ParseDocument(string xml)
 {
     return(EditorXmlNode.ParseDocument(xml, EditorXmlNodeType.NONE));
 }
Exemplo n.º 4
0
    /*
     * private void _ToXmlListIndent (List<string> list, int indent)
     * {
     *      DateTime start = DateTime.Now;
     *      DateTime end;
     *      TimeSpan span;
     *
     *      switch ( type )
     *      {
     *              case XmlNodeType.DOCUMENT:
     *              {
     *                      if ( indent > 0 )
     *                              list.Add (new String (' ', indent * 3));
     *
     *                      foreach (XmlNode node in mChildren)
     *                      {
     *                              node._ToXmlListIndent (list, indent, false);
     *                      }
     *
     *                      break;
     *              }
     *
     *              case XmlNodeType.DECLARATION:
     *              {
     *                      if ( indent > 0 )
     *                              list.Add (new String (' ', indent * 3));
     *
     *                      list.Add ("<?" + name);
     *                      if ( mAttributes.Count != 0 )
     *                      {
     *                              foreach ( XmlNode node in mAttributes )
     *                              {
     *                                      list.Add (" " + node.name + "=\"" + node.content + "\"");
     *                              }
     *                      }
     *                      list.Add ("?>\n");
     *
     *                      break;
     *              }
     *
     *              case XmlNodeType.COMMENT:
     *              {
     *                      if ( indent > 0 )
     *                              list.Add (new String (' ', indent * 3));
     *
     *                      list.Add ("<!--" + content + "-->\n");
     *
     *                      break;
     *              }
     *
     *              case XmlNodeType.TEXT:
     *              {
     *                      list.Add (content);
     *
     *                      break;
     *              }
     *
     *              case XmlNodeType.ELEMENT:
     *              {
     *                      if ( mChildren.Count == 0 )
     *                      {
     *                              if ( indent > 0 )
     *                                      list.Add (new String (' ', indent * 3));
     *
     *                              list.Add ("<" + name);
     *                              if ( mAttributes.Count != 0 )
     *                              {
     *                                      foreach ( XmlNode node in mAttributes )
     *                                      {
     *                                              list.Add (" " + node.name + "=\"" + node.content + "\"");
     *                                      }
     *                              }
     *                              list.Add ("/>\n");
     *                      }
     *                      else
     *                      {
     *                              bool textflag = false;
     *
     *                              XmlNode previous = parent.PreviousChild (this);
     *
     *                              if ( indent > 0 && (previous == null || previous.type != XmlNodeType.TEXT) )
     *                                      list.Add (new String (' ', indent * 3));
     *
     *                              list.Add ("<" + name);
     *                              if ( mAttributes.Count != 0 )
     *                              {
     *                                      foreach ( XmlNode node in mAttributes )
     *                                      {
     *                                              list.Add (" " + node.name + "=\"" + node.content + "\"");
     *                                      }
     *                              }
     *                              list.Add (">");
     *
     *                              if ( mChildren.Count != 0 )
     *                              {
     *                                      if ( mChildren [0].type == XmlNodeType.TEXT )
     *                                              textflag = true;
     *                              }
     *
     *                              if ( !textflag )
     *                                      list.Add ("\n");
     *
     *                              foreach (XmlNode node in mChildren)
     *                              {
     *                                      node._ToXmlListIndent (list, indent + 1, false);
     *                              }
     *
     *                              if ( indent > 0 && !textflag )
     *                                      list.Add (new String (' ', indent * 3));
     *
     *                              list.Add ("</" + name + ">");
     *
     *                              if ( !parent.inline )
     *                                      list.Add ("\n");
     *                      }
     *
     *                      break;
     *              }
     *
     *              case XmlNodeType.UNDEFINED:
     *              {
     *                      if ( indent > 0 )
     *                              list.Add (new String (' ', indent * 3));
     *
     *                      list.Add ("<!-- Undefined node: " + name + " -->");
     *
     *                      break;
     *              }
     *      }
     *
     *      if ( profiling )
     *      {
     *              end = DateTime.Now;
     *              span = end - start;
     *
     *              say ("building string representation using list<string> sequence: " + span.TotalSeconds + " sec");
     *      }
     * }
     */

    public static EditorXmlNode CreateDocument()
    {
        return(EditorXmlNode.ParseDocument(string.Empty));
    }