Example #1
0
        public NanoXmlNode[] SelectNodes(string nodeName)
        {
            var matchedNodes    = new NanoXmlNode[_subNodes.Count];
            int numberOfMatches = 0;

            for (int i = 0; i < _subNodes.Count; i++)
            {
                if (_subNodes[i].Name == nodeName)
                {
                    matchedNodes[numberOfMatches++] = _subNodes[i];
                }
            }

            Array.Resize(ref matchedNodes, numberOfMatches);

            return(matchedNodes);
        }
Example #2
0
        protected NanoXmlDocument(string rawXml)
        {
            int i = 0;

            while (true)
            {
                SkipSpaces(rawXml, ref i);

                if (rawXml[i] != '<')
                {
                    throw new NanoXmlParsingException("Unexpected token");
                }

                i++;                  // skip <

                if (rawXml[i] == '?') // declaration
                {
                    i++;              // skip ?
                    ParseAttributes(rawXml, ref i, _declarations, '?', '>');
                    i++;              // skip ending ?
                    i++;              // skip ending >

                    continue;
                }

                if (rawXml[i] == '!')        // doctype
                {
                    while (rawXml[i] != '>') // skip doctype
                    {
                        i++;
                    }

                    i++; // skip >

                    continue;
                }

                _rootNode = new NanoXmlNode(rawXml, ref i);
                break;
            }
        }