Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MSXML RSS parsing problem

Posted on 2009-05-08
2
Medium Priority
?
235 Views
Last Modified: 2013-11-11
I'm using this code to parse an RSS feed: {Delphi code}

    sCat2 := 'News & Events';
    oChannelNode               := RSSXML.selectsinglenode('rss').firstchild;
    oItemNodes := oChannelNode.selectNodes('//item[category = "'+sCat2+'"]');

    if oItemNodes.length > 0 then // oItemNodes.length is never > 3


It will only return THREE items even though I KNOW there are 4 in the XML.
Any ideas why?
The channel Node XML is posted below.

<channel>
  <SNIP>
  <item>
    <SNIP>
    <category><![CDATA[News & Events]]></category>
    <category><![CDATA[accounts payable]]></category>
    <category><![CDATA[California]]></category>
    <category><![CDATA[new update 8404]]></category>
    <category><![CDATA[New York]]></category>
    <category><![CDATA[Project Management software]]></category>
    <category><![CDATA[tax tables Arizona]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Company News]]></category>
    <category><![CDATA[News & Events]]></category>
    <category><![CDATA[certified payroll]]></category>
    <category><![CDATA[direct deposit]]></category>
    <category><![CDATA[excel time card import]]></category>
    <category><![CDATA[import job estimates]]></category>
    <category><![CDATA[magnetic media]]></category>
    <category><![CDATA[multi-state payroll]]></category>
    <category><![CDATA[subcontractor payment sheets]]></category>
    <category><![CDATA[Tra-Ser integration]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Construction Software]]></category>
    <category><![CDATA[complexities in construction]]></category>
    <category><![CDATA[construction accounting software]]></category>
    <category><![CDATA[entry level software]]></category>
    <category><![CDATA[QuickBooks]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Company News]]></category>
    <category><![CDATA[headquarters]]></category>
    <category><![CDATA[larger offices]]></category>
    <category><![CDATA[PR Newswire]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Construction Software]]></category>
    <category><![CDATA[AccuBuild]]></category>
    <category><![CDATA[commercial industrial construction company]]></category>
    <category><![CDATA[SQL database]]></category>
    <category><![CDATA[tips choosing software]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Stimulus Package & Construction]]></category>
    <category><![CDATA[AGC]]></category>
    <category><![CDATA[Arizona chapter]]></category>
    <category><![CDATA[Obama]]></category>
    <category><![CDATA[press conference]]></category>
    <category><![CDATA[Transportation Department]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[News & Events]]></category>
    <category><![CDATA[AccuBuild construction software]]></category>
    <category><![CDATA[construction software modules features]]></category>
    <category><![CDATA[existing new customer]]></category>
    <category><![CDATA[free users license]]></category>
    <category><![CDATA[special discounts promotion]]></category>
    <category><![CDATA[Spring Into Summer Sale]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[News & Events]]></category>
    <category><![CDATA[attendees]]></category>
    <category><![CDATA[construction industry news]]></category>
    <category><![CDATA[Construction Software]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Stimulus Package & Construction]]></category>
    <category><![CDATA[3.4 billion]]></category>
    <category><![CDATA[construction on sale]]></category>
    <category><![CDATA[economic stimulus package construction companies]]></category>
    <SNIP>
  </item>
  <item>
    <SNIP>
    <category><![CDATA[Construction Software]]></category>
    <category><![CDATA[construction companies profitable]]></category>
    <category><![CDATA[construction specific software]]></category>
    <category><![CDATA[Equipment Module]]></category>
    <category><![CDATA[generating income]]></category>
    <SNIP>
  </item>
</channel>

Open in new window

0
Comment
Question by:EddieShipman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Craig Yellick earned 2000 total points
ID: 24339910
I tested your XML (after deleting all the SNIP) using MS .NET and the expression:

   //item[category='News & Events']

returns 4 item elements, not three. Reasons the expression might yield only 3 hits:

* oChannelNode does not point to the entire XML document you've indicated
* one of the item elements is not lower-case or otherwise exactly "item"
* same as the above for one of the category elements
* the category element content might not be exactly "News & Events"

Try using the following expression (which ignores the item and category element names) and see if it finds 4 items:

  //*[text()='News & Events']

You could also try the above against the RSSXML object and not oChannelNode.

0
 
LVL 26

Author Comment

by:EddieShipman
ID: 24359478
I reworked how I'm doing everything and thus am now satisfied with the results.
I get each category's feed using the ?cat=XXX&feed=rss2 url and then append the items from each into one XML document and then I am able to check for the //item[category = xxx] correctly.
Thanks for the heads up, though.
0

Featured Post

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question