Exemple #1
0
    public void Parse(string text)
    {
        texts.Clear();

        if (string.IsNullOrEmpty(text))
        {
            Debug.LogError("text source was null or empty!");
            return;
        }

        // ex.
        // <root>
        // <key>value</key>\n
        //</root>
        texts = TinyXmlReader.DictionaryFromXMLString(text);

        /*
         * // code for parsing format "key@@@value\n"
         * string[] delimterFields2 = new string[1];
         * delimterFields2[0] = delimiterFields;
         *
         *
         * String[] lines = text.Split(delimiterLines[0]);
         *
         * foreach( String line in lines )
         * {
         *      String[] parts = line.Split(delimterFields2, StringSplitOptions.None);
         *
         *      // completely empty line, skip
         *      if( parts.Length == 1 )
         *      {
         *              continue;
         *      }
         *
         *      // more than 2 fields in a single line is not supported at this time
         *      if( parts.Length != 2 )
         *      {
         *              Debug.LogError("Line didn't contain 2 but "+ parts.Length +" fields "+ delimiterFields +" : " + line);
         *              continue;
         *      }
         *
         *      // make sure key or content is not empty!
         *      if( parts[0] == "" || parts[1] == "" )
         *      {
         *              Debug.LogError("Line key or value is empty : " + line);
         *              continue;
         *      }
         *
         *      texts[ parts[0].Trim() ] = parts[1].Trim();
         * }
         */
    }
Exemple #2
0
 // Parse flat xml data of the form: <key>value</key>
 // The data is considered to be found at depth level 1 (the root and header are found on depth level 0).
 public Dictionary <string, string> ParseFrom(string rawdata)
 {
     return(TinyXmlReader.DictionaryFromXMLString(rawdata));
 }