SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Help a newbie with Powershell and XML?


Help a newbie with Powershell and XML?

Author
Message
Brad Feaker-195979
Brad Feaker-195979
SSC-Addicted
SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)SSC-Addicted (439 reputation)

Group: General Forum Members
Points: 439 Visits: 213
I have an XML file as follows:

<Projects> <Project ProjectName = "DeploymentPackageTest" ProjectFolder = "Test"> <Parameters> <Parameter parmName = "LocalHostTest_ConnectionString" parmDataType = "string" parmReq="True" parmSensitive = "False" parmValue = "Data Source=.;Initial Catalog=TEST;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;" parmDesc = "This is a test"> </Parameter> <Parameter parmName = "TestParameter" parmDataType = "string" parmReq="True" parmSensitive = "False" parmValue = "This is a test" parmDesc = "This is a test"> </Parameter> </Parameters> <Packages> <Package PackageName = "SSISDeploy" varName = "TESTDB_ConnectionString" varValue = "Data Source=.;Initial Catalog=TEST;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False;"> </Package> <Package PackageName = "SSISDeploy" varName = "TheTestParameter" varValue = "This is still a test"> </Package> </Packages> </Project> </Projects>

And this code as follows:

[xml]$XMLProject = Get-Content -Path C:\TEST\XML\SampleProjectsXML2.xml
$ProjectName = $XMLProject.Projects.Project.GetAttribute("ProjectName")
$FolderName = $XMLProject.Projects.Project.GetAttribute("ProjectFolder")

Now I need to read through multiple <Package> and <Parameter> nodes and load their data into an array.

This is where I got lost. My set based brain hurts enough in this object oriented world but I have to make this work.

Help!

Brad Feaker

"Tantum religio potuit suadere malorum." - Lucretius
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search