private void ParseXmlIntoUmbracoNodes()
        {
            // Iterate through each XML element in the config.
            foreach (var element in ParsedXml.Descendants())
            {
                // Elements that have an id and urlName attribute are Umbraco nodes.
                if (element.Attribute("id") != null && element.Attribute("urlName") != null)
                {
                    List <int> nodeIdPaths = GetNodeIdPath(element);
                    int        nodeId      = Convert.ToInt32(element.Attribute("id").Value);

                    var    urlAlias      = element.Element("umbracoUrlAlias");
                    string firstUrlAlias = null;
                    if (urlAlias != null && !string.IsNullOrWhiteSpace(urlAlias.Value))
                    {
                        firstUrlAlias = urlAlias.Value.Split(',')[0];
                    }

                    var url       = GetUrlForNodeIdPaths(nodeIdPaths, firstUrlAlias);
                    var pathNames = GetPathNamesForNodeIdPaths(nodeIdPaths);

                    _nodes[nodeId] = new UmbracoNode(this, nodeId, element, url, nodeIdPaths, pathNames);

                    // Set parent
                    if (_nodes[nodeId].ParentId != null && _nodes.ContainsKey(_nodes[nodeId].ParentId.Value))
                    {
                        _nodes[nodeId].Parent = _nodes[_nodes[nodeId].ParentId.Value];
                    }

                    // Add to the list in order (for multiple enumeration in GetNodes())
                    _nodesInOrder.Add(_nodes[nodeId]);
                }
            }
        }
        private void BuildUrlFragmentCache()
        {
            if (ParsedXml != null)
            {
                foreach (var element in ParsedXml.Descendants())
                {
                    if (element.Attribute("id") != null && element.Attribute("urlName") != null)
                    {
                        var nodeId  = Convert.ToInt32(element.Attribute("id").Value);
                        var urlName = element.Attribute("urlName").Value;

                        // Can be overridden with an umbracoUrlName element
                        if (element.Element("umbracoUrlName") != null && !string.IsNullOrWhiteSpace(element.Element("umbracoUrlName").Value))
                        {
                            urlName = element.Element("umbracoUrlName").Value;
                        }

                        // Node might have a URL prefix configured
                        if (Options.UrlPrefixMapping != null && Options.UrlPrefixMapping.ContainsKey(nodeId))
                        {
                            _urlFragmentCache[nodeId] = Options.UrlPrefixMapping[nodeId];
                        }
                        else
                        {
                            _urlFragmentCache[nodeId] = urlName;
                        }

                        _pathFragmentCache[nodeId] = element.Attribute("nodeName").Value;
                    }
                }
            }
            else if (ParsedTree != null)
            {
                foreach (var nodeId in ParsedTree.Keys)
                {
                    var treeNode = ParsedTree[nodeId];

                    // Save UID
                    _guidToNodeIdMapping[treeNode.Node.Uid.ToString().Replace("-", string.Empty).ToLower()] = nodeId;

                    ContentData dataSource = treeNode.PublishedData;
                    if (dataSource == null)
                    {
                        dataSource = treeNode.DraftData;
                    }

                    if (dataSource != null && !String.IsNullOrEmpty(dataSource.UrlSegment))
                    {
                        var urlName = dataSource.UrlSegment;

                        // Can be overridden with an umbracoUrlName element
                        var umbracoUrlNameProperty = dataSource.Properties.FirstOrDefault(p => p.Key == "umbracoUrlName");
                        if (umbracoUrlNameProperty.Value != null && umbracoUrlNameProperty.Value.FirstOrDefault() != null)
                        {
                            urlName = umbracoUrlNameProperty.Value.FirstOrDefault().Value as string;
                        }

                        // Node might have a URL prefix configured
                        if (Options.UrlPrefixMapping != null && Options.UrlPrefixMapping.ContainsKey(nodeId))
                        {
                            _urlFragmentCache[nodeId] = Options.UrlPrefixMapping[nodeId];
                        }
                        else
                        {
                            _urlFragmentCache[nodeId] = urlName;
                        }

                        _pathFragmentCache[nodeId] = dataSource.Name;
                    }
                }
            }
        }