public String searchTagAttributeValue(Document doc, String rootNodeName, String tag, String attributeName, boolean strict)
            throws TagNotFoundException,
                   AttributeNotFoundException
    {
        NodeList nodes = doc.getElementsByTagName(rootNodeName);

        try
        {
            DOMWalker walker = DOMWalkerFactory.getWalker(WALKER).configure(nodes.item(0), DOMWalker.ELEMENT_NODES);
            while (walker.hasNext())
            {
                Node node = walker.nextNode();
                if (node.getNodeType() == Node.ELEMENT_NODE)
                {
                    if (node.getNodeName().equalsIgnoreCase(tag))
                    {
                        NamedNodeMap attributes = node.getAttributes();
                        if (attributes == null)
                        {
                            if (strict)
                            {
                                throw new AttributeNotFoundException("The tag \"" + tag + "\" does not contain attributes.");
                            }
                            else
                            {
                                return "";
                            }
                        }
                        else
                        {
                            Node attribute = attributes.getNamedItem(attributeName);
                            if (attribute == null)
                            {
                                if (strict)
                                {
                                    throw new AttributeNotFoundException("The attribute \"" + attribute + "\" does not exists.");
                                }
                                else
                                {
                                    return "";
                                }
                            }
                            else
                            {
                                return attribute.getNodeValue();
                            }
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            LOG.error("Error parsing DOM tree. Error: " + e.toString(), e);
        }

        if (strict)
        {
            throw new TagNotFoundException("The tag \"" + tag + "\" was not found in the XML.");
        }
        else
        {
            return "";
        }
    }