Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7634339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:08:48+00:00 2026-05-31T07:08:48+00:00

I am having 3 arrays $IPAddress $VMName $HostName What i would like to do

  • 0

I am having 3 arrays

 $IPAddress
 $VMName
 $HostName

What i would like to do is each value in these arrays should be stored in corresponding XML entries.

For ex. All these 3 arrays are having around 10 entries.

First entry in all the three arrays should be stored in first XML tag, second entries in second XML tag and so on. My XML file should be looks like below.

<VM>
  <IPAddress>IPAddress[0]</IPAddress>
  <VMName>VMName[0]</VMName>
  <HostName>HostName[0]</HostName>
</VM>

<VM>
  <IPAddress>IPAddress[1]</IPAddress>
  <VMName>VMName[1]</VMName>
  <HostName>HostName[1]</HostName>
</VM>

How to store the values into XML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:08:50+00:00Added an answer on May 31, 2026 at 7:08 am
    $pattern = '
    <VM>
      <IPAddress>{0}</IPAddress>
      <VMName>{1}</VMName>
      <HostName>{2}</HostName>
    </VM>
    '
    $elements = 0..($IPAddress.Length-1) | % { $pattern -f $IPAddress[$_], $VmName[$_], $HostName[$_] }
    

    And now simply wrap the $elements in a root and store in a file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three arrays each having SimpleXML Objects in them. They are structured like
I am having an array $IPAddress which contains IPv4 and IPv6 address like below.
I am having two 1D arrays. I want to convert these 2 arrays as
I've two for loops that basically look up in two different arrays (each having
I have three arrays each having different data. I want to join them as
I having two arrays say, $array1 = array(code => E0089, desc => some description);
Hello I'm having problems sending arrays, structs and arrays of structs from PHP to
I am trying new things with arrays and having some difficulty. I am trying
i am having difficulty with 2D arrays and inserting objects that take 3 parameters
I'm having a hard time working with arrays. Coming from AS2/AS3 and garbage collection

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.