Filtering xml file

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
arnold_
Posts: 5
Last visit: Mon Mar 18, 2019 8:18 am

Filtering xml file

Post by arnold_ »

hi,

pls how have to do to creat filter:
okay
$Xml.reconnect.city.count

# filter count?
$Xml.SelectNodes("//2011").Count | where {$_.2011 -gt 0}| Select-Object 2011

# filter list ?
$Xml.SelectNodes("//2011") | where {$_.2011 -gt 0}| Select-Object 2011

Thanks for you help
Arnold

ps : In the TFM books i can't find out (page: 513)
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Filtering xml file

Post by Alexander Riedel »

Found this post in the customer service area. I moved it to the general powershell forum. Please indicate if you still need help with this problem.
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Filtering xml file

Post by jvierra »

I am pretty sure this was answered in the Scripting Guys forum.

To recap - XML tag names cannot begin with a number. The XML is invalid and cannot be queried.

Also - what is this: "ps : In the TFM books i can't find out (page: 513)"
This topic is 10 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked