parsing xml questions

by Sep 22, 2013

I have an xml file, test.xml that looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<PLS Version="2.0" Title="DocTitle">
<Field Name="RecordName">Record1</Field>
<Field Name="RecordNote">Note1</Field>
<Field Name="RecordName">Record2</Field>
<Field Name="RecordNote">Note2</Field>

From the PS cmdline I do:

[xml]$var = get-content .test.xml

The question is, how can I easily reference the text 'Record2' and place it in a variable for instance?

I currently reference this text as $var.PLS.Record[1].Field[0].'#text' and this way I can place it in a variable, but I would rather access it on the actual field name, 'FieldName1'. I tried a million things and googled til I fell asleep.

Imagine I know a record name and want to access this records' note?

Thanks for any help!