I am trying to debug someone else’s PS and would like to know why this would produce a collection instead of just the first RSS “item” in the feed? Where $rssItems is the new collection. I would think you would have to iterate over $content.rss.channel to get all the children (items).
Best guess, it seems like the property item actually has multiple objects underneath it. What does the data look like when you display it? We need more info
RSS feeds can be different and have different data/properties. Have you ran get member on RSSItems to see what it shows? does it show System.Object[]?
I am sorry, I thought I explained this better. The RSS “item” elements are all direct children of the $content.rss.channel element, so all items are siblings of each other directly within the “channel”. Item has its nested children of corresponding data. Here is the actual RSS feed URL. Thanks for your help!
Should output those events immediately without the need to go through the properties. It does more work behind the scenes to get you the intended data.
also great to see another indiana person (assuming anyway…) I work for higher ed in Indiana too :).
Thanks! I am fairly new at PowerShell, so it seems odd to me to only drill down to the “item” property and get an entire collection instead of just the first item. Normally, I would iterate over the .channel collection and push them into an array. Is that exclusive to PS?
I’m not sure, tbh - maybe? I mostly only know PS sorry!
From my limited perspective - it has to do with the XML, but I don’t have the experience to talk intelligently about other programming languages. I wasn’t classically taught in programming.
For this, the ‘Item’ (I know its singular) property is named htat way, because of how the XML is. It’s a ‘collection’, as it contains multiple ‘sub-objects’. The ‘channel’ property does not. Channel is only a ‘single’ object, that has multiple properties, one being Item.
($data.rss.channel).count
outputs a count of 1.
If you look at the channel,
You can see what PS is doing by looking at the data in a web browser:
There’s only ‘1’ root object, but I added a property named Property1, and It is an array of numbers. each item is an INT, but it’s a system.object or collection of objects if I look at it in the whole. There’s still only 1 root object though. The same principal applies here.
Your link about Member-Access Enumeration did clear some things up. I wasn’t totally thinking incorrectly, since prior to PS 3.0 you would have to enumerate through the list items instead. This is a good explanation. Thanks for your help!