PHP help needed

Discussion in 'PHP' started by SunShellNET, Jul 14, 2010.

  1. #1
    Hi
    I have this text

    <lveconfig>
    <defaults>
    <cpu limit=" 21"></cpu>
    <io limit=" 21"></io>
    <other maxentryprocs="   20"></other>
    </defaults>
    </lveconfig>
    Code (markup):
    I would like to get the values

    cpu limit
    and
    io limit from this

    How can I get it using php ?
     
    SunShellNET, Jul 14, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming you have the SimpleXML extension:

    
    <?php
    $string = <<<XML
    <lveconfig>
    <defaults>
    <cpu limit=" 21"></cpu>
    <io limit=" 21"></io>
    <other maxentryprocs="   20"></other>
    </defaults>
    </lveconfig>
    XML;
    
    	$xml = simplexml_load_string($string);
    
    	$cpuLimit = $xml->defaults[0]->cpu->attributes()->limit;
    	$ioLimit  = $xml->defaults[0]->io->attributes()->limit;
    ?>
    
    PHP:
     
    Deacalion, Jul 14, 2010 IP
  3. SunShellNET

    SunShellNET Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Great, thanks a lot
     
    SunShellNET, Jul 14, 2010 IP