www.webdeveloper.com
Results 1 to 3 of 3

Thread: get elements from a XML file as variables

  1. #1
    Join Date
    Apr 2014
    Posts
    4

    get elements from a XML file as variables

    Hi am trying to get some entrys from a xml file:
    Code:
    <license>
    	<server_ip>some ip</server_ip>
    	<domain>some domain</domain>
    	<license_key>some license key</license_key>
    	<allowed>1000</allowed>
    	<used>1</used>
    	<expire>2100-12-31</expire>
    	<update>2014-12-31</update>
            <check>1a1937f9e47ea3d1402749aae9a679c9</check>
    </license>
    What I need is getting the entry's in to variables that I can process with php to check license
    Code:
    $serverip = entry
    $domain = entry
    $license = entry
    $expire = entry
    $update = entry
    $check = entry
    Some of the above is send to license server with CURL rest is just check in my config file.

    Thanks in advance
    Brian Olsen

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,637
    Sounds like a job for SimpleXML?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Apr 2014
    Posts
    2
    $file= file_get_contents("the_file_path_here");
    $xml = new SimpleXmlElement($file);

    $server_ip = $xml->license->server_ip;

    Something like this.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles