EDN Admin
Well-known member
Hi folks,
Im trying to manipulate an XML document using Powershell. the problem Im having is inherently an XPath problem so Im hoping someone here can help.
Basically, in the following document I need to access the <PropertyValue> element where the sibling <PropertyName>="CustomLogPath". At the moment I can only do it using a number index, but thats not good enough. Can anyone help? Its
just an XPath problem, right?
thanks<br/>
Jamie
<pre lang="x-powershell $xml = [xml]<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>CustomDataPath</PropertyName>
<PropertyValue>DATABASEDATA</PropertyValue>
</Property>
<Property>
<PropertyName>CustomLogPath</PropertyName>
<PropertyValue>DATABASELOG</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
$root = $xml.get_DocumentElement();
$root.Properties.Property[1].PropertyValue #Rather than use Property[1] I need something like Property[PropertyName=CustomLogPath][/code]
http://sqlblog.com/blogs/jamie_thomson/ http://sqlblog.com/blogs/jamie_thomson/ |
http://twitter.com/jamiet @jamiet | http://who-can-help.me/profile/view/14
About me <br/>
http://feeds.feedburner.com/%7Er/jamiet/%7E6/1" target="_blank <img src="http://feeds.feedburner.com/jamiet.1.gif" alt="Jamie Thomson" style="border:0pt none
View the full article
Im trying to manipulate an XML document using Powershell. the problem Im having is inherently an XPath problem so Im hoping someone here can help.
Basically, in the following document I need to access the <PropertyValue> element where the sibling <PropertyName>="CustomLogPath". At the moment I can only do it using a number index, but thats not good enough. Can anyone help? Its
just an XPath problem, right?
thanks<br/>
Jamie
<pre lang="x-powershell $xml = [xml]<?xml version="1.0" encoding="utf-8"?>
<SqlCommandVariables xmlns="urn:Microsoft.VisualStudio.Data.Schema.Package.SqlCmdVars
<Version>1.0</Version>
<Properties>
<Property>
<PropertyName>CustomDataPath</PropertyName>
<PropertyValue>DATABASEDATA</PropertyValue>
</Property>
<Property>
<PropertyName>CustomLogPath</PropertyName>
<PropertyValue>DATABASELOG</PropertyValue>
</Property>
</Properties>
</SqlCommandVariables>
$root = $xml.get_DocumentElement();
$root.Properties.Property[1].PropertyValue #Rather than use Property[1] I need something like Property[PropertyName=CustomLogPath][/code]
http://sqlblog.com/blogs/jamie_thomson/ http://sqlblog.com/blogs/jamie_thomson/ |
http://twitter.com/jamiet @jamiet | http://who-can-help.me/profile/view/14
About me <br/>
http://feeds.feedburner.com/%7Er/jamiet/%7E6/1" target="_blank <img src="http://feeds.feedburner.com/jamiet.1.gif" alt="Jamie Thomson" style="border:0pt none
View the full article