Re: [xml] xmlNodePtr properties missing xmlns:xxxx




Thank you both.  I have solved the problem thus:

void CXbrl::RegisterNamespaces(xmlDocPtr pXmlDoc,
                             xmlXPathContextPtr pXPathCtx)
{
    m_mNamespaces.clear();
    RegisterNamespaces(pXmlDoc->children, pXPathCtx);
}


void CXbrl::RegisterNamespaces(xmlNodePtr pNode,
                             xmlXPathContextPtr pXPathCtx)
{
   xmlNodePtr pCurNode = NULL;

   for (pCurNode = pNode; pCurNode; pCurNode = pCurNode->next)
   {
      if (pCurNode) 
      {
         xmlNsPtr pNs = pCurNode->nsDef;
 
         while (pNs)
         {
            xmlXPathRegisterNs(pXPathCtx, pNs->prefix, pNs->href);

            //  Add namespace to map if not already added:
            string sPrefix = XmlChar2String(pNs->prefix);
            string sHref   = XmlChar2String(pNs->href);

            NAMESPACES_TYPE::iterator pos = m_mNamespaces.find(sHref);

            if (pos == m_mNamespaces.end())
            {   // we will be searching on HREFs:
            m_mNamespaces.insert(NAMESPACES_TYPE::value_type(sHref, sPrefix));          
            }

            pNs = pNs->next;
         }
      }

      RegisterNamespaces(pCurNode->children, pXPathCtx);
   }
}
-- 
View this message in context: 
http://old.nabble.com/xmlNodePtr-properties-missing-xmlns%3Axxxx-tp31911110p31917973.html
Sent from the Gnome - Lib - Xml - General mailing list archive at Nabble.com.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]