Results 1 to 7 of 7

Thread: PHP XML -

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jun:2011
    Location: Sofia
    Posts: 3

    PHP XML -

    !

    , .

    mysql c php XML DOM functions.

    XML-a :

    Code:
    <markers>
    <DEVS DEVICE="DEV10">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A57" TIME="18:16:40" />
    </DEVS>
    <DEVS DEVICE="DEV10">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    </DEVS>
    <DEVS DEVICE="DEV5">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    </DEVS>
    <DEVS DEVICE="DEV5">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    </DEVS>
    </markers>
    :

    Code:
    <markers>
    <DEVS DEVICE="DEV10">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A57" TIME="18:16:40" />
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    </DEVS>
    <DEVS DEVICE="DEV5">
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    <marker USER="PRIVET_!" DATA1="0578" DATA2="0A55" TIME="18:16:05" />
    </DEVS>
    </markers>
    TAG, Unique, , DEV10 1 DEV10, .

    , :

    PHP Code:
    <?php  

    require("config.php"); 

    // Start XML file, create parent node

    $dom = new DOMDocument("1.0");
    $node $dom->createElement("markers");
    $parnode $dom->appendChild($node); 

    // Opens a connection to a MySQL server

    $connection=mysql_connect ($server$db_user$db_pass);
    if (!
    $connection) {  die('Not connected : ' mysql_error());} 

    // Set the active MySQL database

    $db_selected mysql_select_db($database$connection);
    if (!
    $db_selected) {
      die (
    'Can\'t use db : ' mysql_error());


    // Select all the rows in the markers table

    $query "SELECT * FROM input WHERE (DEVS = 'DEV5' or DEVS = 'DEV10')  ORDER BY TIME DESC";
    $result mysql_query($query);
    if (!
    $result) {  
      die(
    'Invalid query: ' mysql_error());


    header("Content-type: text/xml"); 

    // Iterate through the rows, adding XML nodes for each

    while ($row = @mysql_fetch_assoc($result)){  
      
    // ADD TO XML DOCUMENT NODE  
      
    $node1 $dom->createElement("DEVS");
      
    $parnode->appendChild($node1);
      
    $marker $dom->createElement("marker");
      
    $node1->appendChild($marker);
      
      
    $marker->setAttribute("USER"$row['USER']);
      
    $marker->setAttribute("DATA1"$row['DATA1']);  
      
    $marker->setAttribute("DATA2"$row['DATA2']);  
      
    $marker->setAttribute("TIME"$row['TIME']); 
      
    $node1->setAttribute("DEVICE"$row['DEVS']);

    }

    echo 
    $dom->saveXML();

    ?>
    , .

  2. #2
    Registered User
    Join Date: Dec:2003
    Posts: 2,817
    - ? DOMDocument ?
    Gigabyte DS3P, E4400@9x333, 2x2Gb Super T@1000Mhz, Gigabyte GTX460OC 768Mb

  3. #3
    Registered User
    Join Date: Jun:2011
    Location: Sofia
    Posts: 3
    ? , . DOMDocument , , XML, DOM - . , .

  4. #4
    Random User |ma3x|Virus's Avatar
    Join Date: Aug:2003
    Location:
    Posts: 331
    ,
    PHP ,
    XML-a ti .
    saveXML()
    XML. Self enclosed tags, custom print method.
    Free Your Mind!!!

  5. #5
    Registered User
    Join Date: Jun:2011
    Location: Sofia
    Posts: 3
    , php code XML-a . xml, , . , , , javascript.

  6. #6
    Registered User
    Join Date: Jul:2005
    Location: Sofiq
    Posts: 2,798
    javascript - JSON ? json_encode json_decode php.

  7. #7
    Vesu's Avatar
    Join Date: May:2004
    Location: Zurich
    Posts: 1,319
    spy_eye, :

    DEVS (order by DEVS).
    while, ( ), $node1 = $dom->createElement("DEVS"); node- ( ).

Posting Permissions

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

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |