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 8557801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:39:25+00:00 2026-06-11T15:39:25+00:00

Below you will find my xml document: <?xml version=1.0 encoding=ISO-8859-1?> <app> <version>0925</version> <humanVersion>0.9.25</humanVersion> </app>

  • 0

Below you will find my xml document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<app>
    <version>0925</version>
    <humanVersion>0.9.25</humanVersion>
</app>

Here is my php:

$completeurl = "ota/shingle/shingle.xml";
$xml = simplexml_load_file($completeurl);
$updateVer = $xml->version;
$updateVerHuman = $xml->humanVersion;

I am taking the php variables and putting them into a json string, here is the output:

{“updateVer”:{“0″:”0925″},”updateVerHuman”:{“0″:”0.9.25”}}

Why is the updateVer and updateVerHuman data enclosed in {} and contains “0”:?? I would like only the data in that value. How do I achieve this?

I have tried this but it produces the same result:

$updateVer = $xml->version[0];
$updateVerHuman = $xml->humanVersion[0];
  • 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-06-11T15:39:26+00:00Added an answer on June 11, 2026 at 3:39 pm

    When you access any child element (or even attribute) with SimpleXML, you get back another SimpleXML object – this is why you can write things like $node->child->grand_child.

    In order to get just the string content of a particular bit of XML, you need to “cast” the SimpleXML object to a string, using (string)$variable.

    Sometimes, this will happen for you – notably, since you can’t echo anything other than a string, echo $variable will always cast to a string for you. However, as a rule of thumb, always cast SimpleXML objects to string to avoid later confusion.

    In your example, $updateVer and $updateVerHuman are both still objects when you turn them to JSON. $updateVer = (string)$xml->version; $updateVerHuman = (string)$xml->humanVersion; should give the expected result.

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

Sidebar

Related Questions

I have an XML document that looks like this: <?xml version=1.0 encoding=UTF-8?> <xs:msgdata xmlns:xs=http://www.myCompany.com
XML element I am accessing: is here, if below sample is unreadable: http://api.petfinder.com/pet.find?&animal=dog&count=150&location=90605&key=a94884c2349b5b6975ec84fb51ac3ec4 <pets>
Below you will find my current vHost entry that I am using for a
I'm doing a homework project that requires this: Below you will find the code
thanks for taking the time to stop by my question. Below you will find
I have an xml file like below which I will use to set background
The code below will validate required fields within currently visible fieldsets, but only if
The HTML below will show a page with 2 buttons. One will open a
Doing the below will reproduce my problem: New WPF Project Add ListView Name the
The code below will report Syntax error message: type 'a edge = |Empty |End

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.