BOOL vmsMetalinkFile::Parse(LPCSTR pszFile)
{
	USES_CONVERSION;

	IXMLDOMDocumentPtr spXML;
	IXMLDOMNodePtr spNode;

	spXML.CreateInstance (__uuidof (DOMDocument));

	if (spXML == NULL)
		return FALSE;

	spXML->put_async (FALSE);

	VARIANT_BOOL bRes;
	spXML->load (COleVariant (pszFile), &bRes);
	if (bRes == FALSE)
		return FALSE;

	spXML->selectSingleNode (L"metalink", &spNode);
	if (spNode == NULL)
		return FALSE;

	IXMLDOMNodeListPtr spNodeList;
	spNode->get_childNodes (&spNodeList);

	if (spNodeList == NULL)
		return FALSE;

	IXMLDOMNodePtr spItem;

	BOOL bHasOkFilesNode = FALSE;

	while (SUCCEEDED (spNodeList->nextNode (&spItem)) && spItem != NULL)
	{
		CComBSTR bstrName;
		spItem->get_nodeName (&bstrName);

		if (bstrName == L"description")
		{
			CComBSTR bstrText;
			spItem->get_text (&bstrText);
			m_strDescription = W2A (bstrText);
		}

		else if (bstrName == L"files")
		{
			if (ReadFilesNode (spItem))
				bHasOkFilesNode = TRUE;
		}

		spItem = NULL;
	}

	return bHasOkFilesNode;
}
BOOL CDlgExportDownloads::ExportDownloads_ToDLInfoListFile(LPCSTR pszFile, DLDS_LIST* pvpDlds, BOOL bAppend)
{
    IXMLDOMDocumentPtr spXML;
    IXMLDOMNodePtr spNode, spNode2;

    spXML.CreateInstance (__uuidof (DOMDocument));

    if (spXML == NULL)
        return FALSE;

    spXML->put_async (FALSE);

    VARIANT_BOOL bRes = FALSE;
    if (bAppend)
    {
        spXML->load (COleVariant (pszFile), &bRes);
        if (bRes)
        {
            spXML->selectSingleNode (L"FDM_Downloads_Info_List", &spNode);
            if (spNode == NULL)
                bRes = FALSE;
        }
    }

    if (bRes == FALSE)
    {
        spXML->createNode (COleVariant ((long)NODE_ELEMENT), L"FDM_Downloads_Info_List", NULL, &spNode);
        spXML->appendChild (spNode, &spNode2);
    }

    for (size_t i = 0; i < pvpDlds->size (); i++)
    {
        ExportDownload_ToXML (spXML, spNode, pvpDlds->at (i));
    }

    CComBSTR bstr;
    spXML->get_xml (&bstr);

    CString str = bstr;
    str.Replace ("><", ">\n<");

    bstr = str;

    spXML->loadXML (bstr, &bRes);

    spXML->save (COleVariant (pszFile));

    return TRUE;
}
Exemplo n.º 3
0
BOOL vmsVideoSiteHtmlCodeParser::Parse_Further_MySpace(LPCSTR pszHtml)
{
	USES_CONVERSION;
	IXMLDOMDocumentPtr spXML;
	IXMLDOMNodePtr spNode, spNode2;

	while (*pszHtml && *pszHtml != '<')
		pszHtml++;

	spXML.CreateInstance (__uuidof (DOMDocument));

	if (spXML == NULL)
		return FALSE;

	spXML->put_async (FALSE);

	VARIANT_BOOL bRes;
	spXML->loadXML (A2W (pszHtml), &bRes);
	if (bRes == FALSE)
		return FALSE;

	spXML->selectSingleNode (L"rss", &spNode);
	if (spNode == NULL)
		return FALSE;

	spNode->selectSingleNode (L"channel", &spNode2);
	if (spNode2 == NULL)
		return FALSE;

	spNode = NULL;
	spNode2->selectSingleNode (L"item", &spNode);
	if (spNode == NULL)
		return FALSE;

	spNode2 = NULL;
	spNode->selectSingleNode (L"title", &spNode2);
	if (spNode2 == NULL)
		return FALSE;

	CComBSTR bstrTitle;
	spNode2->get_text (&bstrTitle);

	spNode2 = NULL;
	spNode->selectSingleNode (L"media:content", &spNode2);
	if (spNode2 == NULL)
		return FALSE;
	IXMLDOMNamedNodeMapPtr spAttrs;
	spNode2->get_attributes (&spAttrs);
	if (spAttrs == NULL)
		return FALSE;
	IXMLDOMNodePtr spUrlValue;
	spAttrs->getNamedItem (L"url", &spUrlValue);
	if (spUrlValue == NULL)
		return FALSE;
	COleVariant vtUrl;
	spUrlValue->get_nodeValue (&vtUrl);
	ASSERT (vtUrl.vt == VT_BSTR);
	if (vtUrl.vt != VT_BSTR)
		return FALSE;

	m_strVideoTitle = W2A (bstrTitle);
	fsDecodeHtmlText (m_strVideoTitle);
	m_strVideoUrl   = W2A (vtUrl.bstrVal);
	m_strVideoType  = (LPCSTR)m_strVideoUrl + m_strVideoUrl.GetLength () - 3;
	m_bDirectLink	= TRUE;

	return TRUE;
}