Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Help: how to get link addres in the RSS XML file in MFC/C++?

Help: how to get link addres in the RSS XML file in MFC/C++?

Scheduled Pinned Locked Moved XML / XSL
tutorialc++xmlhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fujoey
    wrote on last edited by
    #1

    I have to parse RSS channel definition XML file. I have appended one sample at the end of this topic. I have installed MSXML parser 6 and uses it successfully. Please refer to function XmlRSSRead. There are a lot of information about the channel and item of this channel. For example, one channel has title, link, description information. One channel may have a lot of item too. Each item also hase title, link, description information. I have to extract title, link, description information in my application. I can not find one quick start guide from microsoft doucments. Could anyone be kind to tell me what I should do next? The following is the function I have now and the xml file I want to parse. void XmlRSSRead( void ) { //¡ä¡ä?¡§DOMDocument???¨® MSXML2::IXMLDOMDocumentPtr pDoc; HRESULT hr = pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30)); if(!SUCCEEDED(hr)) { AfxMessageBox( _T("?T¡¤¡§¡ä¡ä?¡§DOMDocument???¨®¡ê????¨¬2¨¦¨º?¡¤?¡ã2¡Á¡ã¨¢?MS XML Parser ??DD?a!") ); } //?¨®?????t pDoc->load( _T("D:\\temp\\mPhone\\Docs\\RSS\\nature.xml") ); //?¨²¨º¡Â?D2¨¦?¨°???achannel¦Ì??¨²¦Ì?, // "//"¡À¨ª¨º??¨²¨¨?¨°a¨°?2?2¨¦?¨° MSXML2::IXMLDOMElementPtr childNode ; childNode = (MSXML2::IXMLDOMElementPtr)(pDoc->selectSingleNode("//channel")); //¦Ì?¦Ì??¨²¦Ì?¨¤¨¤D¨ª MSXML2::DOMNodeType nodeType; childNode->get_nodeType(&nodeType); //?¨²¦Ì???3? BSTR var; CString name; childNode->get_nodeName(&var); name = (char*)(_bstr_t)var; //?¨²¦Ì??¦Ì VARIANT varVal; childNode->get_nodeTypedValue(&varVal); CString strValue = (char*)(_bstr_t)varVal; //?¨²¦Ì?¨º?D?,¡¤??¨²¨¢¡ä¡À¨ª?D MSXML2::IXMLDOMNamedNodeMapPtr pAttrs = NULL; MSXML2::IXMLDOMNodePtr pAttrItem; childNode->get_attributes(&pAttrs); long nCount ; pAttrs->get_length(&nCount); for(int i = 0 ; i < nCount ; i++) { pAttrs->get_item(i,&pAttrItem); //?¨°???¨¦¨°?¨ª¡§1yo¡¥¨ºyget_nodeName,get_nodeTypedValue¦Ì?¦Ì?¨º?D???o¨ª¨º?D??¦Ì //¨°2?¨¦¨°??¡À?¨®¦Ì?¦Ì? CString strAttrName = (char*)(_bstr_t)pAttrItem->nodeName; CString strAttrValue = (char*)(_bstr_t)pAttrItem->nodeTypedValue; } } void mfXmlReadTest( void ) { ::CoInitialize(NULL); MSXML2::IXMLDOMDocumentPtr spPtr; HRESULT hr = spPtr.CreateInstance(__uuidof(MSXML2::DOMDocument30)); ASSERT(SUCCEEDED(hr)); spPtr->loadXML("\ntop\nbottom\n"); spPtr->save("C:\\nature.xml"); spPtr.Release(); ::CoUninitialize(); } XMLÎļþÈçÏ£º

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups