Beispiel #1
0
CStdString SmartTagParser::GetTextForSmartTagName(const CStdString & SmartTagName)
{
    if (m_spXMLDom == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetTextForSmartTagName - The XML document pointer is null."));
        throw Workshare::NullReferenceException(msg);
    }

    CComBSTR nodeText = _T("//");
    nodeText += GetNamespacePrefix();
    nodeText += _T(":");
    nodeText += SmartTagName;

    MSXML2::IXMLDOMNodePtr pNode = m_spXMLDom->selectSingleNode(nodeText.m_str);

    if (pNode == NULL)
    {
        CStdString msg;
        msg.Format(_T("SmartTagParser::GetTextForSmartTagName - Failed to get node (%s) from the XML"), nodeText);
        throw Workshare::Exception(msg);
    }

    CStdString sValue = pNode->text;

    if (pNode)
    {
        pNode.Release();
    }

    return sValue;
}
Beispiel #2
0
WideString CFX_XMLElement::GetNamespaceURI() const {
  WideString attr(L"xmlns");
  WideString wsPrefix = GetNamespacePrefix();
  if (!wsPrefix.IsEmpty()) {
    attr += L":";
    attr += wsPrefix;
  }
  const CFX_XMLNode* pNode = this;
  while (pNode) {
    if (pNode->GetType() != FX_XMLNODE_Element)
      break;

    auto* pElement = static_cast<const CFX_XMLElement*>(pNode);
    if (!pElement->HasAttribute(attr)) {
      pNode = pNode->GetParent();
      continue;
    }
    return pElement->GetAttribute(attr);
  }
  return WideString();
}