Reading XML is incredibly basic, you start by reading the file in like this:

$config = [xml](get-content $path)

Then from there you can refer to the $config variable like it was actually a 
strongly typed object. For example, say I wanted to read through all of the 
appSettings from a web.config file, I would go into a loop like this:

foreach ($addNode in $config.configuration.appsettings.add) { }

So here I have the configuration tag, which has an appsettings tag, and then 
multiple add tags within that. The same process applied for properties of tags 
as well, PowerShell figures out what you are trying to get to and does a pretty 
good job of it I've found.

Once you have all the data from the XML though, it's just a matter of pulling 
out the SharePoint API through PowerShell, so something like this might help:

$web = Get-SPWeb http://YourUrlHere
$list = $web.Lists.get_Item("List name")

Then the $list object is just an SPList, so you can call to add items to it the 
same as you would through the object model.


[cid:image002.png@01CC08BC.54384730]

Brian Farnhill
Solutions Architect, Extelligent Design | SharePoint Server MVP
phone: 0408 289 303 | twitter: @BrianFarnhill<http://twitter.com/BrianFarnhill> 
| blog: blog.brianfarnhill.com<http://blog.brianfarnhill.com/> | xbox: Noble 
Downfall<http://live.xbox.com/en-AU/MyXbox/Profile?gamertag=Noble+Downfall>



From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Monday, 2 May 2011 11:19 AM
To: ozMOSS
Subject: RE: Load data from XML file to SharePoint library as metadata

Hi Brian,

Do you have any examples?

I'd like to do the same thing. We have an XML doc which I want to use as the 
"source of truth" to populate several list copies in different sites.

I was looking at a web service or workflow but PowerShell sounds like it might 
be more straightforward.

Regards,

Paul

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Brian Farnhill
Sent: Monday, 2 May 2011 11:12 AM
To: ozMOSS
Subject: RE: Load data from XML file to SharePoint library as metadata

A PowerShell script could do that pretty easy - reading XML with PowerShell is 
insanely easy, and putting the data in to SharePoint is pretty straight forward 
as well.

[cid:image003.png@01CC08BC.54384730]

Brian Farnhill
Solutions Architect, Extelligent Design | SharePoint Server MVP
phone: 0408 289 303 | twitter: @BrianFarnhill<http://twitter.com/BrianFarnhill> 
| blog: blog.brianfarnhill.com<http://blog.brianfarnhill.com/> | xbox: Noble 
Downfall<http://live.xbox.com/en-AU/MyXbox/Profile?gamertag=Noble+Downfall>



From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Amar Pabla
Sent: Monday, 2 May 2011 10:57 AM
To: ozmoss@ozmoss.com
Subject: Load data from XML file to SharePoint library as metadata

Hi All

Our CRM system generates thousands of XML files, these files contains data such 
as member number, name and surname.

I want to load these data items as metadata into SharePoint library for each 
XML file.

What is the best way to achieve this?

Thank you in advance.

Amar



Amar Pabla
Process Improvement Manager
MDA National
MDA National Insurance Pty Ltd
Level 3 / 516 Hay Street - Subiaco WA 6008
PO Box 1557 - Subiaco WA 6904
Freecall 1800 011 255
Ph: +618 6461 3423
Fax: +618 9415 1493
0447 891 738
www.mdanational.com.au<http://www.mdanational.com.au/>
Please consider the environment before printing this email

Confidentiality Notice
The information contained in this email may be confidential information, and 
may also be the subject of legal professional privilege. If you are not the 
intended recipient, any use, disclosure or copying of this email is 
unauthorised. If you have received this email in error, please delete it and 
immediately notify us via reply email.

Privacy Notice<http://www.mdanational.com.au/privacy-policy.aspx>
MDA National collects personal information to provide and market our services. 
We may share personal information with other organisations that assist us in 
doing this. You may access personal information we hold about you, subject to 
the Federal Privacy Act. For more information visit our 
website<http://www.mdanational.com.au/privacy-policy.aspx> or email us at 
priv...@mdanational.com.au<mailto:priv...@mdanational.com.au>

<<inline: image002.png>>

<<inline: image003.png>>

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to