0

Let us suppose that i have an array with 5 elements in it.

$fruits[$a] - {fox,apple,tiger,lion,rose}

i want these items to be fetched from this array and to be printed in an XML file in the following format :

    <elements>

    <elements scope="items">fox</elements>
    <elements scope="items">apple</elements>
    <elements scope="items">tiger</elements>
    <elements scope="items">lion</elements>
    <elements scope="items">rose</elements>

    </elements>

I am unable to fetch the data in the above mentioned format... instead by my script i am getting the elements in the following format (which is not required)

    <elements>

    <elements scope="items">fox apple tiger lion rose[0]</elements>
    <elements scope="items">fox apple tiger lion rose[1]</elements>
    <elements scope="items">fox apple tiger lion rose[2]</elements>
    <elements scope="items">fox apple tiger lion rose[3]</elements>
    <elements scope="items">fox apple tiger lion rose[4]</elements>

    </elements>

I've tried

For($a=0;$a -lt $elements;$a++) { 
  $arte[$a] = Split-Path $arte[$a]-Leaf $global:xmlWriter.WriteRaw("<elements scope="items">$arte[$a]</elements>") #Write-Host $arte[$a]; 
}
Gourav Bid
  • 23
  • 5
  • 1
    You should show the script you're using. – Chris N Jan 21 '16 at 14:54
  • @GouravBid, I've added that to your post, but in the future just edit your post instead of posting it as a comment – Dan Field Jan 21 '16 at 15:09
  • @Chris - Below is the part of script i am using to get this done - For($a=0;$a -lt $artefacts;$a++) { $arte[$a] = Split-Path $arte[$a]-Leaf $global:xmlWriter.WriteRaw("$arte[$a]") #Write-Host $arte[$a]; } – Gourav Bid Jan 21 '16 at 15:11
  • @DanField - can you please repost the comment. and sorry for the inconvenience but i am new to this site and still don't know how to format part of the codes in the comments... – Gourav Bid Jan 21 '16 at 15:13
  • There's an edit link under the tags in your post. You should really post a bit more of your script - try reading http://stackoverflow.com/help/mcve – Dan Field Jan 21 '16 at 15:14

0 Answers0