Click here to Skip to main content
15,914,066 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: C++ Help Needed Pin
bob1697214-Oct-07 7:53
bob1697214-Oct-07 7:53 
GeneralRe: C++ Help Needed Pin
vivekphlp14-Oct-07 18:36
vivekphlp14-Oct-07 18:36 
QuestionWhich statements are correct? Pin
ComplexLifeForm13-Oct-07 8:03
ComplexLifeForm13-Oct-07 8:03 
AnswerRe: Which statements are correct? Pin
Mark Salsbery13-Oct-07 8:19
Mark Salsbery13-Oct-07 8:19 
GeneralRe: Which statements are correct? Pin
ComplexLifeForm13-Oct-07 9:39
ComplexLifeForm13-Oct-07 9:39 
GeneralRe: Which statements are correct? Pin
Mark Salsbery13-Oct-07 9:54
Mark Salsbery13-Oct-07 9:54 
AnswerRe: Which statements are correct? Pin
Mike Dimmick14-Oct-07 10:39
Mike Dimmick14-Oct-07 10:39 
QuestionHelp: how to get link addres in the RSS XML file in MFC/C++? Pin
fujoey13-Oct-07 6:10
fujoey13-Oct-07 6:10 
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("<r>\n<t>top\nbottom\n");
spPtr->save("C:\\nature.xml");
spPtr.Release();
::CoUninitialize();
}


XMLÎļþÈçÏ£º

<rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
<channel>
<title>Nature Podcast
http://www.nature.com/nature/podcast/rss/nature.xml <description>Nature is a weekly international journal publishing the finest peer-reviewed research in all fields of science. The Nature Podcast is a free weekly audio show highlighting content from each issue, and interviews with the scientists creating the data. The Nature Podcast provides insight and context to groundbreaking research, and allows the scientists to explain the significance of their work in their own words.
<language>en
<copyright>© 2006 Nature Publishing Group
<lastbuilddate>Wed, 25 Jul 2007 18:00:00 GMT
<category>Science & Medicine
<category>Technology

<url>http://www.nature.com/nature/podcast/images/nature_rss_logo.png
<title>Nature
http://www.nature.com/nature/podcast/rss/nature.xml <width>144
<height>144

<itunes:author>Nature
<itunes:subtitle>Interviews, insight and highlights of the latest scientific discoveries, every week in Nature
<itunes:summary>Nature is a weekly international journal publishing the finest peer-reviewed research in all fields of science. The Nature Podcast is a free weekly audio show highlighting content from each issue, and interviews with the scientists creating the data. The Nature Podcast provides insight and context to groundbreaking research, and allows the scientists to explain the significance of their work in their own words.
<itunes:owner>
<itunes:name>Nature
<itunes:email>podcast@nature.com

<itunes:category text="Science & Medicine">
<itunes:category text="Technology">
<itunes:image href="http://www.nature.com/nature/podcast/images/nature_itunes_logo.png">
<item>
<title>Nature Podcast: 26 July 2007
http://www.nature.com/nature/podcast/v448/n7152/nature-2007-07-26.mp3 <description>?26 July: Rain changes of our own making, science in the Simpsons, Californian-style plate rifts, investigating inflammatory bowel disease, pygmies with palm pilots.
<guid>http://www.nature.com/nature/podcast/v448/n7152/nature-2007-07-26.mp3
<enclosure url="http://www.nature.com/nature/podcast/v448/n7152/nature-2007-07-26.mp3" length="13343922" type="audio/mpeg">

<pubdate>Wed, 25 Jul 2007 18:00:00 GMT
<category>Science & Medicine
<category>Technology
<itunes:author>Nature
<itunes:subtitle>?26 July: Rain changes of our own making, science in the Simpsons, Californian-style plate rifts, investigating inflammatory bowel disease, pygmies with palm pilots.
<itunes:duration>37:03
<itunes:explicit>no
<itunes:category text="Science & Medicine">
<itunes:category text="Technology">
<itunes:keywords>nature, podcast, science, technology, education, science news, biology, physics, genetics, astronomy, astrophysics, quantum physics, evolution, evolutionary biology, geophysics, climate change, earth science, materials science, science policy, medicine, systems biology, genomics, palaeobiology, ecology, molecular biology, cancer, immunology, pharmacology, developmental biology, biochemistry, bioinformatics, nanotechnology, biotechnology, drug discovery, environmental science, life, marine biology, medical research, neuroscience, rna, dna, cell cycle, signal transduction, cell signalling



AnswerRe: Help: how to get link addres in the RSS XML file in MFC/C++? Pin
Mike Dimmick14-Oct-07 10:43
Mike Dimmick14-Oct-07 10:43 
QuestionHow can i Add a set of integers to my ComboBox Pin
saravana00113-Oct-07 5:58
saravana00113-Oct-07 5:58 
AnswerRe: How can i Add a set of integers to my ComboBox Pin
Mark Salsbery13-Oct-07 6:18
Mark Salsbery13-Oct-07 6:18 
GeneralRe: How can i Add a set of integers to my ComboBox Pin
chandu00413-Oct-07 7:32
chandu00413-Oct-07 7:32 
GeneralRe: How can i Add a set of integers to my ComboBox Pin
Mark Salsbery13-Oct-07 7:37
Mark Salsbery13-Oct-07 7:37 
GeneralRe: How can i Add a set of integers to my ComboBox Pin
Mark Salsbery13-Oct-07 7:42
Mark Salsbery13-Oct-07 7:42 
GeneralRe: How can i Add a set of integers to my ComboBox Pin
chandu00413-Oct-07 8:04
chandu00413-Oct-07 8:04 
GeneralRe: How can i Add a set of integers to my ComboBox Pin
Hamid_RT13-Oct-07 8:27
Hamid_RT13-Oct-07 8:27 
Questiongetting character position from mouse position Pin
LejonO13-Oct-07 1:39
LejonO13-Oct-07 1:39 
AnswerRe: getting character position from mouse position Pin
Mark Salsbery13-Oct-07 6:25
Mark Salsbery13-Oct-07 6:25 
GeneralRe: getting character position from mouse position Pin
LejonO13-Oct-07 7:01
LejonO13-Oct-07 7:01 
GeneralRe: getting character position from mouse position Pin
Mark Salsbery13-Oct-07 7:11
Mark Salsbery13-Oct-07 7:11 
GeneralRe: getting character position from mouse position Pin
LejonO13-Oct-07 11:24
LejonO13-Oct-07 11:24 
GeneralRe: getting character position from mouse position Pin
Mark Salsbery13-Oct-07 11:32
Mark Salsbery13-Oct-07 11:32 
GeneralRe: getting character position from mouse position Pin
LejonO13-Oct-07 22:25
LejonO13-Oct-07 22:25 
GeneralRe: getting character position from mouse position Pin
Mark Salsbery14-Oct-07 5:46
Mark Salsbery14-Oct-07 5:46 
QuestionMSWord Automation through vc++ Pin
chandu00413-Oct-07 0:36
chandu00413-Oct-07 0:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.