当前位置: 首页>>代码示例>>C++>>正文


C++ XmlDocument::GetNodeValue方法代码示例

本文整理汇总了C++中appsecinc::xml::XmlDocument::GetNodeValue方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlDocument::GetNodeValue方法的具体用法?C++ XmlDocument::GetNodeValue怎么用?C++ XmlDocument::GetNodeValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appsecinc::xml::XmlDocument的用法示例。


在下文中一共展示了XmlDocument::GetNodeValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testGetNodeValue

void XmlDocumentUnitTests::testGetNodeValue()
{	
	struct testGetNodeValue_TestData
	{
		LPCWSTR xpath;
		LPCWSTR result;
		LPCWSTR xml;
	};

	std::wstring xmlfile = GetLocalFileLocation(L"store.xml");
	std::wcout << std::endl << L"Xml: " << xmlfile;
	AppSecInc::Xml::XmlDocument xml;
	xml.Load(xmlfile, CLSID_DOMDocument);

    testGetNodeValue_TestData testdata[] = 
    {
        { L"/bookstore/book[@id=1]/title", L"'Emma'", L"<title xmlns=\"http://www.lucernepublishing.com\">'Emma'</title>" }
    };

    for (int i = 0; i < ARRAYSIZE(testdata); i++)
    {
        // default value
		std::wstring default_value = xml.GetNodeValue(L"/invalid/xpath", NULL, L"default");
		std::wcout << std::endl << L"Value: " << default_value;
		CPPUNIT_ASSERT(L"default" == default_value);
		// value
		std::wstring result_value = xml.GetNodeValue(testdata[i].xpath);
		std::wcout << std::endl << L"Value: " << result_value;
		CPPUNIT_ASSERT(testdata[i].result == result_value);
		// xml
		std::wstring result_xml = xml.GetNodeXml(testdata[i].xpath);
		std::wcout << std::endl << L"Xml: " << result_xml;
		CPPUNIT_ASSERT(testdata[i].xml == result_xml);
    }
}
开发者ID:MariusCC,项目名称:msiext,代码行数:35,代码来源:XmlDocumentUnitTests.cpp

示例2: msiInstall

CA_API UINT __stdcall LocalGroupMembers_Deferred(MSIHANDLE hInstall)
{
	MSI_EXCEPTION_HANDLER_PROLOG;
    MsiInstall msiInstall(hInstall);

    AppSecInc::Xml::XmlDocument xmlDocument;
    xmlDocument.LoadXml(msiInstall.GetActionData());

    MSXML2::IXMLDOMNodeListPtr rows = xmlDocument.SelectNodes(L"/LocalGroupMembers/LocalGroupMember");
    MSXML2::IXMLDOMNodePtr row = NULL;
    while (NULL != (row = rows->nextNode()))
    {
        std::wstring id = xmlDocument.GetAttributeValue(L"id", row);
        std::wstring username = xmlDocument.GetNodeValue(L"Username", row);
        std::wstring groupname = xmlDocument.GetNodeValue(L"Group", row, L"");
        bool add_member = xmlDocument.GetAttributeBoolValue(L"add", row);
        bool remove_member = xmlDocument.GetAttributeBoolValue(L"remove", row);
        bool check = xmlDocument.GetAttributeBoolValue(L"check", row);

        if (remove_member && (! check || AppSecInc::LSA::LocalGroup::IsMember(groupname, username)))
        {
            msiInstall.LogInfo(_T(__FUNCTION__), L"Removing \"" + username + L"\" from \"" + groupname + L"\"");
            AppSecInc::LSA::LocalGroup::DeleteMember(groupname, username);
        }

        if (add_member && (! check || ! AppSecInc::LSA::LocalGroup::IsMember(groupname, username)))
        {
            msiInstall.LogInfo(_T(__FUNCTION__), L"Adding \"" + username + L"\" to \"" + groupname + L"\"");
            AppSecInc::LSA::LocalGroup::AddMember(groupname, username);
        }
    }

	MSI_EXCEPTION_HANDLER_EPILOG;
    return ERROR_SUCCESS;
}
开发者ID:MariusCC,项目名称:msiext,代码行数:35,代码来源:LocalGroupMembers.cpp

示例3: msiInstall

CA_API UINT __stdcall TemplateFiles_Deferred(MSIHANDLE hInstall)
{
	MSI_EXCEPTION_HANDLER_PROLOG;
    MsiInstall msiInstall(hInstall);

    AppSecInc::Xml::XmlDocument xmlDocument;
    xmlDocument.LoadXml(msiInstall.GetActionData());

    MSXML2::IXMLDOMNodeListPtr rows = xmlDocument.SelectNodes(L"//TemplateFile[@execute='true']"); // \todo //Row[@rollback='false']
    MSXML2::IXMLDOMNodePtr row = NULL;
    while (NULL != (row = rows->nextNode()))
    {
        std::wstring id = xmlDocument.GetAttributeValue(L"id", row);
        std::wstring source = xmlDocument.GetNodeValue(L"Source", row);
        std::wstring target = xmlDocument.GetNodeValue(L"Target", row, source);

		msiInstall.LogInfo(L"TemplateFiles_Deferred", source + L" => " + target);

        std::map<std::wstring, std::wstring> properties;

        {
            MSXML2::IXMLDOMNodeListPtr property_rows = xmlDocument.SelectNodes(L"Properties/Property", row);
            MSXML2::IXMLDOMNodePtr property_row = NULL;
            while (NULL != (property_row = property_rows->nextNode()))
            {
                std::wstring name = xmlDocument.GetAttributeValue(L"name", property_row);
                std::wstring value = xmlDocument.GetAttributeValue(L"value", property_row);
                long escape = AppSecInc::StringUtils::stringToLong(xmlDocument.GetAttributeValue(L"escape", property_row, L"0"));
                properties[name] = escape == 1 ? AppSecInc::StringUtils::escape(value) : value;
            }
        }

        std::wstring data;
        bool utf8 = AppSecInc::File::ReadAndConvertToEnd(source, data);
        data = AppSecInc::Formatter::FormatTemplate(data, properties);

		std::string char_data;
		if (utf8) 
		{
			char_data = AppSecInc::StringUtils::wc2utf8(data);
			char_data.insert(0, std::string(reinterpret_cast<char *>(AppSecInc::File::utf8_bom)));
		}
		else
		{
			char_data = AppSecInc::StringUtils::wc2mb(data);
		}

        std::vector<char> binary_data;
        binary_data.assign(char_data.begin(), char_data.end());

        AppSecInc::File::FileWrite(target, binary_data);
    }

	MSI_EXCEPTION_HANDLER_EPILOG;
    return ERROR_SUCCESS;
}
开发者ID:wojwal,项目名称:msiext,代码行数:56,代码来源:TemplateFiles.cpp

示例4: testExecute

void MsiDatabaseUnitTests::testExecute()
{
    std::wstring filename = AppSecInc::File::GetTemporaryFileNameW();
    std::wcout << std::endl << L"Creating " << filename;
    MsiDatabase database;
    database.Create(filename);
    std::wcout << std::endl << L"Database handle " << std::hex << (MSIHANDLE) database;

    std::wstring path = File::GetModuleDirectoryW() + L"\\TestData_MsiUnitTests";
	database.Execute(L"CREATE TABLE `Property` (`Property` CHAR(72) NOT NULL, `Value` CHAR(0) NOT NULL LOCALIZABLE PRIMARY KEY `Property`)");
	database.Execute(L"INSERT INTO `Property` (`Property`, `Value`) VALUES ('ProductCode', '{72B62622-57A8-46ac-A12A-7669772D35DA}')");
    database.Commit();
    database.Close();

    MsiPackage package(filename);
    MsiInstall install(package);

    AppSecInc::Xml::XmlDocument xmlDoc;
    xmlDoc.LoadXml(install.GetViewData(L"SELECT `Value` FROM `Property` WHERE `Property`='ProductCode'"));
    std::wstring value = xmlDoc.GetNodeValue(L"/Table/Row/Data[@Column=\"Value\"]");
    std::wcout << std::endl << L"Data: " << value;
    CPPUNIT_ASSERT(value == L"{72B62622-57A8-46ac-A12A-7669772D35DA}");
    package.Close();
    
    AppSecInc::File::FileDelete(filename);
}
开发者ID:MariusCC,项目名称:msiext,代码行数:26,代码来源:MsiDatabaseUnitTests.cpp

示例5: testImport

void MsiDatabaseUnitTests::testImport()
{
    std::wstring filename = AppSecInc::File::GetTemporaryFileNameW();
    std::wcout << std::endl << L"Creating " << filename;
    MsiDatabase database;
    database.Create(filename);
    std::wcout << std::endl << L"Database handle " << std::hex << (MSIHANDLE) database;

    std::wstring path = File::GetModuleDirectoryW() + L"\\TestData_MsiUnitTests";
	database.Import(path, L"Property.idt"); 
    database.Import(path, L"ComboBox.idt"); 
    database.Commit();
    database.Close();

    MsiPackage package(filename);
    MsiInstall install(package);

    AppSecInc::Xml::XmlDocument xmlDoc;
    xmlDoc.LoadXml(install.GetViewData(L"SELECT * FROM `ComboBox`"));
    std::wstring value = xmlDoc.GetNodeValue(L"/Table/Row/Data[@Column=\"Property\"]");
    std::wcout << std::endl << L"Data: " << value;
    CPPUNIT_ASSERT(value == L"DATABASE_SERVER");
    package.Close();
    
    AppSecInc::File::FileDelete(filename);
}
开发者ID:MariusCC,项目名称:msiext,代码行数:26,代码来源:MsiDatabaseUnitTests.cpp

示例6: msiInstall

CA_API UINT __stdcall Xml_SelectNodeValue(MSIHANDLE hInstall)
{
    MSI_EXCEPTION_HANDLER_PROLOG;
    MsiInstall msiInstall(hInstall);

    std::wstring filename = msiInstall.GetProperty(L"XML_FILENAME");
    AppSecInc::Xml::XmlDocument doc;
    doc.Load(filename);

    std::wstring xpath = msiInstall.GetProperty(L"XML_XPATH");

    std::wstring value = doc.GetNodeValue(xpath);
    msiInstall.SetProperty(L"XML_NODEVALUE", value);

    MSI_EXCEPTION_HANDLER_EPILOG;
    return ERROR_SUCCESS;
}
开发者ID:stephenwelsh,项目名称:msiext,代码行数:17,代码来源:XmlToolsImpl.cpp

示例7: Load

void AccessDatabase::Load(AppSecInc::Xml::XmlDocument& xmldoc, MSXML2::IXMLDOMNodePtr root)
{
    _dbq = xmldoc.GetNodeValue(L"DBQ", root);
    _connection_string = AppSecInc::Crypt::DPAPIImpl::UnProtect(xmldoc.GetNodeValue(L"ConnectionString", root, L""));
}
开发者ID:MariusCC,项目名称:msiext,代码行数:5,代码来源:AccessDatabase.cpp


注:本文中的appsecinc::xml::XmlDocument::GetNodeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。