Enhancement - copy all parents of a child node in either slash or dot format
JeffBenedict opened this issue · 9 comments
Disclaimer: Please move if this enhancement request is in the wrong place. Please excuse my terminology syntax if it's incorrect.
It would be nice to have another "copy" option (Copy Parents for example) that could copy all the parents of a child node as either a slash or dot format.
For example: given the following simple XML :
<channel>
<source>
<properties>
<enabled>
true
</enabled>
</properties>
</source>
</channel>
if "true" is selected, then the Edit/Copy Parents command or Right Click/Copy Parents command would put into the clipboard either
channel/source/properties/enabled
or
channel.source.properties.enabled
(or options for both)
This for me would be extremely useful when using Powershell to parse XML files and pull data out.
How about "Copy Path" which would produce an XPath expression (the same one you see in the Find Dialog when you select XPath). For the above the xpath is "channel/source/properties/enabled" but let's say there were 5 blocks and this was the last one the xpath can also pinpoint the location using expressions like this "channel/source/properties[5]/enabled"
Yes, I believe that would work, and then for me, I could replace the / with dots in my Powershell stuff.
or your powershell could use xpath:
[xml]$xml = Get-Content 'C:\path\to\your.xml'
$xml.selectNodes('channel/source/properties[5]/enabled')
thanks for the info. i'm doing mine something like this: (of course it's a little bit more complex), and I'm probably making it more complex that it really needs to be. but it works .. for me.. :)
$configfile = 'c:\path\to\myfile.xml'
$config = [xml]::new()
$config.load($configfile)
$channel = $config.channel.source
then i can iterate thru the properties with something liek
foreach ($property in $channel.properties) {
do something,
like look for $property.enabled
}
that's fine if it works for you but my understanding is the "." access to elements only works for singleton elements, whereas the xpath is more general and can handle finding things that are buried in collections.
i understand. my particular case with this powershell script is to do a selective parsing of a very complex xml and populate certain data in specific columns and rows on specific tabs in an excel spreadsheet...
Ok, I added new "Copy XPath" command to the Edit and Context menus which will be available in version 2.9.0.7 shortly.
Awesome. Cant wait for the update to be available.
Release 2.9.0.7 is now available.