Jump to content

Search the Community

Showing results for tags 'xml'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. I have the following code which works just fine sending the $xml. However when i try to add a file to be sent with the xml as well i get an error. I tried using a postData array but then got an array to string error. The way i have it now works but it only sends the xml not the file. Any ideas on how I can send the @file with the postfields? Any help is appreciated $header = array('Content-Type: multipart/form-data'); $xml['xml'] = '<UploadPhoto>'; $xml['xml'] .= '<ID>12345</ID>'; $xml['xml'] .= '<PhotoID>myphoto</PhotoID>'; $xml['xml'] .= '<Filename>myphoto.jpg</Filename>'; $xml['xml'] .= '<Instructions>Need cheeks less rosy</Instructions>'; $xml['xml'] .= '</UploadPhoto>'; $postData = array( 'file' => '@/myphoto.jpg', 'xml' => $xml ); } $connection = curl_init(); curl_setopt($connection, CURLOPT_URL, "http://www.myurl.com/api"); curl_setopt($connection, CURLOPT_HTTPHEADER, $header); curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($connection, CURLOPT_POST, 1); curl_setopt($connection, CURLOPT_POSTFIELDS, $xml); curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); set_time_limit(108000); $output = curl_exec($connection); curl_close($connection); print_r($output);
  2. hi i wonder if someone can help i have some code to make a simple XML output <?php header('Content-type: text/xml'); header('Pragma: public'); header('Cache-control: private'); header('Expires: -1'); echo "<?xml version=\"1.0\" encoding=\"utf-8\"?> <xml> <customers> <id>song_path</id> <name>David</name> <promos> D123OO M876TT B765DC LO122M </promos> </customers> </xml>"; ?> my problem is; when the XML is displayed in the browser, it forces the values in <promos> onto 1 line <promos>D123OO M876TT B765DC LO122M</promos> is it possible to keep the formatting, so it outputs <promos> D123OO M876TT B765DC LO122M </promos> i have tried lots of different things but nothing seems to work \r\n \n\r \n \r <br /> <p> the only option which came close was <br />, but the XML actually displays the <br /> tag can anyone help? thank you
  3. When using the following code: $yaxis=array(); $xaxis=array(); for ($i = 1; $i <= $number_of_entries; $i++) { $channel = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.Channel']/ns:Value"); $channel = $channel[0]; $xaxis[]=$channel[0]; $apcount = $xml->xpath("//ns:BulkData[ns:Name='InternetGatewayDevice.LANDevice.1.WLANConfiguration.X_181BEB_ChannelDiagnostics.Result.{$i}.APcount']/ns:Value"); $apcount = $apcount[0]; $yaxis[]=$apcount[0]; } I get the following results for $xaxis and $yaxis arrays: print_r($xaxis); Array ( [0] => SimpleXMLElement Object ( [0] => 1 ) [1] => SimpleXMLElement Object ( [0] => 6 ) [2] => SimpleXMLElement Object ( [0] => 11 ) ) print_r($yaxis); Array ( [0] => SimpleXMLElement Object ( [0] => 3 ) [1] => SimpleXMLElement Object ( [0] => 8 ) [2] => SimpleXMLElement Object ( [0] => 6 ) ) What I am looking for is only the value of the nested array. Like this: print_r($xaxis); Array ( [0] => 1 [1] => 6 [2] => 11 ) print_r($yaxis); Array ( [0] => 3 [1] => 8 [2] => 6 ) How can I achieve this? Thanks for any help / suggestions!
  4. Hello, I have one tar.Z file. I have to run shell script daily as it is required to update the database. customer_yyyymmdd_hhmi.tar.Z sales_ yyyymmdd_hhmi.csv (5 MB - 20 MB) purchase_ yyyymmdd_hhmi.xml (650 MB - 950 MB) I have made small part of XML file. There are 4 parts. There is PHP Script which is working but i need to change each time file like PART1.xml, PART2.xml etc. Things to do: 1) Extract tar.Z file and Read CSV and XML file. 2) Read whole XML file automatically. I hope i am clear. Thanks in advanced for your time and input.
  5. I am looking at an xml that has the greater than sign inside the attribute value. <CATEGORY id='163' name='Toys > Other '></CATEGORY> My job is to create a similar xml where the > sign exists inside the node's attribute value ? is this possible ? how ? I tried this: $catName = htmlspecialchars_decode(str_replace('-', '>',$CategoryName )) ; but it just encoded the > into > . Thanks
  6. I need some help to understand the validation of xPath expression in PHP. I want to validate if a xPath expression is correct before i pass it to DOMXPath::query.
  7. I would like to get Type, Id and Height values in database table. It is not working. There is no error message. XML File: <?xml version="1.0" encoding="utf-8"?> <Physical> <Catalog> <EquipmentSpec> <Reference>030_17</Reference> <Type>Duplexeur</Type> <Characteristic><CharacteristicName>Tilt</CharacteristicName> <CharacteristicValue>0</CharacteristicValue></Characteristic> </EquipmentSpec> <EquipmentSpec> <Reference>030_19</Reference> <Type>Node</Type> <Characteristic><CharacteristicName>Tilt</CharacteristicName> <CharacteristicValue>0</CharacteristicValue></Characteristic> </EquipmentSpec> </Catalog> <Installed> <Equipment> <Id>26</Id><Reference>MAT_4</Reference> <Characteristic><CharacteristicName>Height</CharacteristicName><CharacteristicValue>160</CharacteristicValue></Characteristic> </Equipment> <Equipment> <Id>27</Id><Reference>MAT_6890</Reference> <Characteristic><CharacteristicName>Height</CharacteristicName><CharacteristicValue>180</CharacteristicValue></Characteristic> </Equipment> </Installed> </Physical> CODE: foreach ($xml->xpath('Physical') as $spec) { foreach ($spec->xpath('//EquipmentSpec') as $sub) { $Type = $sub->Type; } foreach ($spec->xpath('//Equipment') as $eq) { $Id = $eq->Id; foreach ($eq->Characteristic as $c) { if ($c->CharacteristicName == 'Height') { $Height = $c->CharacteristicValue; } } } $sql = "INSERT INTO machines (`Type`,`Id`,`Height`) VALUES ('".$Type."','".$Id."','".$Height."')"; $req = new requete($site->db, $sql); echo $sql; }
  8. Hello, I would like to know how i can develop interface between XML and MDB files? Actually, i need to convert files from XML into MDB and vice versa. Approximately, how much time it will take?
  9. Hey, I'm trying to pass get variables through an https ssl secured url to generate xml data so I can parse it and I'm not sure how to get it working. I have the following code, I have the url set up like this, $xml = ' weight_system="IMPERIAL" shipper_number="000222000" destination_postal_code="'.$data5['zip'].'" service_type="1" '; $xml2 = ' total_pieces="'.$value.'" total_weight="'.$weight.'" '; $token = 'token'; $base_url = 'https://www.shippingco.com/XML/RatingXML.jsp'; $request_url = $base_url . '?' . http_build_query(array( 'shipment' => '<shipment ' . $xml . '><total ' . $xml2 . '/></shipment>', 'token' => $token )); and I have an example of the xml data here, <rating xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.shippingco.com/XML/rating.xsd"> <rate weight="5.0" weight_unit="lb" zone="3" transit_time="1" transit_time_guaranteed="false" estimated_delivery_date="2013-07-26" base_charge="11.05" freight_charge="11.05"residential_address_charge="2.75" net_charge="13.80" fuel_surcharge_rate="15.8" fuel_surcharge="1.75" subtotal_charge="15.55" on_hst_charge="2.02" total_charge="17.57"/> </rating> I have an RSA key, SSL cert, CA bundle and a password and need to use that information to authenticate with the https url. What is the best working way to accomplish this?
  10. Hey, I'd like to grab xml data by passing get variables through an https ssl secured url and then parse it. What would be the best way to go about doing that and is there a solid tutorial with step by step on how to do that? Thanks for your time!
  11. Hello All, I would like to get all Equipment values. I have used DOM Document. It is reading ONLY LAST Element. Equipment Id: 28. I need all three. Thanks in advanced. XML File: <?xml version="1.0" encoding="UTF-8"?> -<Physical> <Catalog> </Catalog> -<Installed> -<Equipment> <Id>26</Id> <Ref>Tew12</Ref> -<Characteristic> <CharacteristicName>Height</CharacteristicName> <CharacteristicValue>160</CharacteristicValue> </Characteristic> -<Characteristic> <CharacteristicName>Tilt</CharacteristicName> <CharacteristicValue>30</CharacteristicValue> </Equipment> -<Equipment> <Id>27</Id> <Ref>Tew13</Ref> -<Characteristic> <CharacteristicName>Height</CharacteristicName> <CharacteristicValue>165</CharacteristicValue> </Characteristic> -<Characteristic> <CharacteristicName>Tilt</CharacteristicName> <CharacteristicValue>50</CharacteristicValue> </Equipment> -<Equipment> <Id>28</Id> <Ref>Tew14</Ref> -<Characteristic> <CharacteristicName>Height</CharacteristicName> <CharacteristicValue>190</CharacteristicValue> </Characteristic> -<Characteristic> <CharacteristicName>Tilt</CharacteristicName> <CharacteristicValue>50</CharacteristicValue> </Equipment> </Installed> </Physical> Expected Result: Id 26 Tilt 30 Id 27 Tilt 50 Id 28 Tilt 50 For the moment, i am trying to get all Ids values. Still it is not giving ALL Ids. It should give Ids: 26 27 28 $Equipments = $dom->getElementsByTagName('Equipment'); foreach( $Equipments as $Equipments ) { $Ids = $Equipments->getElementsByTagName( 'Id' ); $Id = $Ids->item(0)->nodeValue; echo $Id; }
  12. <?xml version="1.0" encoding="utf-8"?> <home> <firstHeader>Welcome to my Site</firstHeader> <firstParagraph>You are here because your not there.</firstParagraph> <secondParagraph>You are Ugly because we are beautiful</secondParagraph> <thirdParagraph>If there no ugly people then there is no beautul people.</secondParagraph> <question>Make sense right?</question> </home> How do I translate the data of the xml file to other language? Anyones have an idea? or what tools should I use?
  13. Good day, I have a task that require the page to be translated to other language. What the MAN want is to pass all the content of a page to an XML file and then translate all the content and return it in a language choosen. My question is, is this possible? if it is where will I start , cause I don't know really about XML. . By the way I'm using a framework codeigniter, I tried the localization function of the codeigniter and It was okay but it is not the MAN wants. Maybe anyone knows something about codeigniter that can help me. .
  14. Hi all, I have a problem with a crosstable. I want to auto fill the empty cell with black background. The code now downloads the xml and fills each cell with the proper content, but leaves some empte with cells. As for now I have the following structure where [bLACK] at this points still is white without content <table> [bLACK][2][3][4] [1][bLACK][3][4] [1][2][bLACK][4] [1][2][3][bLACK] </table> $countries = array(); $dom = new DOMDocument(); $dom->load('http://www.antilopen.nl/competitie/kruistabel.asp?ci=314&xml=314&t=1'); echo "<table>"; $aantalrijen=$dom->getElementsByTagName('row')->length-1; for ($i = 0 ; $i <= $aantalrijen ; $i++) { ?> <tr class="<?php echo ($clrCounter++ % 2 == 0 ? 'odd' : 'even'); ?>"> <? foreach ($dom->getElementsByTagName('rij_'.$i) as $entry) { echo "<td style=\"padding: 10px\">"; echo $entry->nodeValue; echo "</td>"; } echo "</tr>"; } echo "</table>"; ?>
  15. I have been googling the crap out of this, and I can not find the answer. I've been working on a flash game for quite some time now, and I want to incorporate an online saving ystem. I already understand that getting this to work involves XML and PHP. I already have a small script that displays a change log that I can update when I want, sort of acts as a place holder so things can stay organized. The swf in question is being hosted in my dropbox account, so servers have already been covered. I already know how to communicate between the AS files, XML files, and PHP files, but I can't seem to find any thing on how to save/write information that's been fed to the PHP/XML codes. How would I go about this?
  16. Hi All, I`m pretty new with php but i`m trying to build a mobile page with xml extraction. I`m getting my xml data from an externa site trough simplexml and I want to sort this data on weeknumber, and within the weeknumber on team. The xml data that i`m requesting is <Datum_Tijd> and I want to transform it to a weeknumber.: xml code: <code> A2M 7688 15-5-2013 19:30:00 IJsselvogels A2 DVS '69 A1 7 8 </code> Until now I have this to witdraw my content: <code> <table cellpadding="1px" width="100%"> <tr align="left"> <th>Datum</th><th>Tijd</th><th>Thuis Ploeg</th><th>Uit Ploeg</th><th>Uitslag</th> </tr> <?php foreach ($xml->row AS $info ) { ?> <tr class="<?php echo ($clrCounter++ % 2 == 0 ? 'odd' : 'even'); ?>"> <td><?php $date = date_create($info -> Datum_Tijd); echo date_format($date, 'd-m');?></td> <td><?php $date = date_create($info -> Datum_Tijd); echo date_format($date, 'H:i');?></td> <td <?php if (strpos($info -> Thuisploeg,'IJsselvogels') !== false) {echo 'style="color: #FF0000;"';} ?> ><?php echo $info -> Thuisploeg ?></td> <td <?php if (strpos($info -> Uitploeg,'IJsselvogels') !== false) {echo 'style="color: #FF0000;"';} ?> ><?php echo $info -> Uitploeg ?></td> <td><?php echo $info -> Scorethuis . " - " . $info -> Scoreuit ?></td> </tr> <? }?> </code> But I want: Week 14: result team1 result team2 etc. week 13: result team1 result team2 etc. can you help?
  17. Hallo allemaal, Ik heb via een xml data uit een kruistabel gehaald, en deze netjes in een tabel geplaatst. Tot zover gaat het allemaal goed. Maar ik wil graag de niet gebruikte cellen in de kruistabel zwart vullen, zodat je direct ziet dat deze niet gebruikt wordt: Een voorbeeld van de xml is: <root> <row> <Klasse>A1F</Klasse> <rij_0/> <rij_1>Fortuna A2</rij_1> <rij_2>IJsselvogels A1</rij_2> <rij_3>KCR A2</rij_3> <rij_4>KOAG A1</rij_4> <rij_5>KVS A2</rij_5> <rij_6>ODO A1</rij_6> <rij_7>Vitesse A1</rij_7> <rij_8>Weidevogels A1</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>Fortuna / MHIR A2</rij_0> <rij_1/> <rij_2>8 - 20</rij_2> <rij_3>6 - 8</rij_3> <rij_4>5 - 17</rij_4> <rij_5/> <rij_6>10 - 17</rij_6> <rij_7>9 - 9</rij_7> <rij_8>14 - 16</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>IJsselvogels A1</rij_0> <rij_1/> <rij_2/> <rij_3>14 - 14</rij_3> <rij_4>5 - 8</rij_4> <rij_5>11 - 8</rij_5> <rij_6/> <rij_7>9 - 6</rij_7> <rij_8>13 - 13</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>KCR A2</rij_0> <rij_1>16 - 11</rij_1> <rij_2>7 - 17</rij_2> <rij_3/> <rij_4>7 - 13</rij_4> <rij_5>13 - 5</rij_5> <rij_6>7 - 12</rij_6> <rij_7/> <rij_8>11 - 10</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>KOAG A1</rij_0> <rij_1/> <rij_2>7 - 6</rij_2> <rij_3>13 - 7</rij_3> <rij_4/> <rij_5>17 - 3</rij_5> <rij_6>18 - 8</rij_6> <rij_7>14 - 7</rij_7> <rij_8>15 - 6</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>KVS A2</rij_0> <rij_1>10 - 9</rij_1> <rij_2>7 - 17</rij_2> <rij_3>11 - 7</rij_3> <rij_4>4 - 16</rij_4> <rij_5/> <rij_6>6 - 18</rij_6> <rij_7>8 - 17</rij_7> <rij_8/> </row> <row> <Klasse>A1F</Klasse> <rij_0>ODO A1</rij_0> <rij_1>10 - 5</rij_1> <rij_2>10 - 4</rij_2> <rij_3/> <rij_4>9 - 10</rij_4> <rij_5>19 - 11</rij_5> <rij_6/> <rij_7/> <rij_8>13 - 7</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>Vitesse A1</rij_0> <rij_1>17 - 6</rij_1> <rij_2/> <rij_3>14 - 5</rij_3> <rij_4>9 - 11</rij_4> <rij_5>16 - 10</rij_5> <rij_6>8 - 9</rij_6> <rij_7/> <rij_8>9 - 7</rij_8> </row> <row> <Klasse>A1F</Klasse> <rij_0>Weidevogels A1</rij_0> <rij_1>14 - 9</rij_1> <rij_2>12 - 15</rij_2> <rij_3>12 - 8</rij_3> <rij_4/> <rij_5>7 - 7</rij_5> <rij_6>13 - 14</rij_6> <rij_7>9 - 11</rij_7> <rij_8/> </row> </root> Zijn er mensen die er ervaring mee hebben? Vraag 2: Ik heb nu handmatig de rijen 0 - 8 als rij ingevoerd, is het mogelijk om de rijen automatisch op basis van de xml te vullen, en daarnaast ook de velden in de <th> velden om die automatisch te vullen? Kruistabel <table cellpadding="1px" width="100%"> <tr align="left"> <th><?php echo $kruistabel -> rij_0 ?></th><th><?php echo $kruistabel -> rij_1 ?></th><th><?php echo $kruistabel -> rij_2 ?></th><th><?php echo $kruistabel -> rij_3 ?></th><th><?php echo $kruistabel -> rij_4 ?></th><th><?php echo $kruistabel -> rij_5 ?></th> </tr> <? foreach ( $xmlkruis->row AS $kruistabel ) { ?> <tr class="<?php echo ($clrCounter++ % 2 == 0 ? 'odd' : 'even'); ?>"> <td><?php echo $kruistabel -> rij_0 ?></td> <td><?php echo $kruistabel -> rij_1 ?></td> <td><?php echo $kruistabel -> rij_2 ?></td> <td><?php echo $kruistabel -> rij_3 ?></td> <td><?php echo $kruistabel -> rij_4 ?></td> <td><?php echo $kruistabel -> rij_5 ?></td> <td><?php echo $kruistabel -> rij_6 ?></td> <td><?php echo $kruistabel -> rij_7 ?></td> <td><?php echo $kruistabel -> rij_8 ?></td> </tr> <?}?> </table>
  18. Hoi Allemaal, Ik ben nog redelijk nieuw met het programmeren van PHP en ben bezig met een mobiele pagina. Ik haal via xml gegevens van een externe site en wil deze weergeven op de pagina. De pagina laat gegevens uit de xml zien maar wil deze nu sorteren op weeknummer. De XML gegevens die ik opvraag is, waarbij ik <Datum_Tijd> gebruik om de weeknummer te bepalen: <root> <row> <Klassenaam>A2M</Klassenaam> <Wedstrijdnummer>7688</Wedstrijdnummer> 15-5-2013 19:30:00 <Thuisploeg>IJsselvogels A2</Thuisploeg> <Uitploeg>DVS '69 A1</Uitploeg> <Scorethuis>7</Scorethuis> <Scoreuit>8</Scoreuit> <Opmerking/> </row> <row> Tot dusver heb ik dit, dit laat keurig de uitslagen zien: natuurlijk na het laden van de xml met simplexml: <table cellpadding="1px" width="100%"> <tr align="left"> <th>Datum</th><th>Tijd</th><th>Thuis Ploeg</th><th>Uit Ploeg</th><th>Uitslag</th> </tr> <?php foreach ($xml->row AS $info ) { ?> <tr class="<?php echo ($clrCounter++ % 2 == 0 ? 'odd' : 'even'); ?>"> <td><?php $date = date_create($info -> Datum_Tijd); echo date_format($date, 'd-m');?></td> <td><?php $date = date_create($info -> Datum_Tijd); echo date_format($date, 'H:i');?></td> <td <?php if (strpos($info -> Thuisploeg,'IJsselvogels') !== false) {echo 'style="color: #FF0000;"';} ?> ><?php echo $info -> Thuisploeg ?></td> <td <?php if (strpos($info -> Uitploeg,'IJsselvogels') !== false) {echo 'style="color: #FF0000;"';} ?> ><?php echo $info -> Uitploeg ?></td> <td><?php echo $info -> Scorethuis . " - " . $info -> Scoreuit ?></td> </tr> <? }?> Maar ik wil dus (waarbij de weeknummer de afgelopen 2 weken zijn): Week 14: uitslag team1 uitslag team2 etc. week 13: uitslag team1 uitslag team2 etc. Kunnen jullie helpen?
  19. XPATH method for retuning multiple dynamic results from a XML file using PHP I have a form that the user types or selects a value the form is as follows <form id="search_photos" action="photo_result.php" method="get"> <input value="" name="photographer_id" id="photographer_id" style=" border:1px solid Silver;" type="text"> <select name="Photographer" id="Photographer" style="height:23px; border:1px solid Silver;"> <option selected="selected" value="x">Any Photographer</option> <option value="John">John</option> <option value="Fred">Fred</option> <option value="Joseph">Joseph</option> </select> <select name="images" id="images" style="height:23px; border:1px solid Silver;"> <option selected="selected" value="x">All Images</option> <option value="0">None</option> <option value="a">Image a</option> <option value="b">Image b </option> <option value="c">Image c </option> </select> <input name="Submit" value="Search Now >" id="Submit" class="Adv1_Filter_Button" type="submit"> </form> Then the search_photo.php script that catches the result of the form and filters the values entered by the user as follows <?php $xml = simplexml_load_file("photo.xml"); for ($i = 0; $i < count($xml); $i++){ if(isset($_GET["LocationName"])) { $photographer_id = $_GET["LocationName"]; } $result = $xml->xpath('/root/area[photographer_id=' . $photographer_id . '] '); } if(isset($_GET["Photographer"])) { $photographer = $_GET["Photographer"]; } $result = $xml->xpath('/root/area[photographer_id=' . $photographer_id . '] '); if(isset($_GET["images"])) { $image = $_GET["images"]; } echo $photographer_id; echo $photographer; echo $image; var_dump ($result); ?> The $result from the first XPATH pass is correct if all that is set is ‘photographer_id’ if I then try $result=$xml->xpath ('/root/area[photographer_id=' . $photographer_id . '] | /root/area[photographer=' . $photographer .']'); and select 1 and fred then I get the result of an array of all four when it should be an empty array I have trie & (and) insted of | (or) but just returns an empty array should I convert the $result to an object or is the a way of saving the $result to an xml file
  20. Cannot receive HTTP POST data from Device Magic (DM) form automation website. I get this error: Fatal error: Call to a member function getName() on a non-object in /portfolio/submissions/index.php on line 8 For this code: <?php $raw_body = file_get_contents("php://input"); $xml = simplexml_load_string($raw_body); echo $xml->getName()."\n<br />"; ?> So Instead I try with FireFox REST client (and use the data that should be sent from DM) and do the same as written in my first post and I get a reply - the root node name. Why does the FF REST client work and my website does not? Many thanks
  21. Hi all I've got a slight problem adding some XML data to a MySQL database. My code looks like: // Load XML file $xml = simplexml_load_file('products.xml') or die ("Could not load XML file"); // Database variables $host = "localhost"; $username = "user_name"; $password = "pass_word"; $dbname = "database_name"; // Foreach piece of XML data - send to MySQL database and put into the xmlFeed_db database foreach ($xml->product as $data) { // MySQL connect to database $con = mysql_connect("$host", "$username", "$password") or die ("Unable to connect to database"); $select_db = mysql_select_db($dbname) or die ("Unable to select database"); // Put all data into numerous variables $id = $data->id; $man = $data->manufacturers; $des = $data->description; $price = $data->price; $sku = $data->sku; $category = $data->category; $subcategory = $data->subcategory; // SQL statement $query = "INSERT INTO tablename VALUES ('$id','$man','$des','$price','$sku','$category','$subcategory')"; // Execute SQL statement mysql_query($query) or die ("Insertion Error: " . mysql_error()); // Close MySQL mysql_close(); When I run this script it only stores 249 rows out of 2000 and then it shows an error stating: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's)', '117.08','CAB-OCTAL-ASYNC=','Networking','Networking Cables')' at line 1" Does anyone know why this error message is showing? I've looked at my syntax but I can't see a problem. Maybe a fresh pair of eyes can help. Thanks
  22. Trying to get XML POSTed to my website using the code below: To test that I am getting anything (which I do not at the moment) to my website I use this code: print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />"; $data = file_get_contents('php://input'); print "DATA: <pre>"; var_dump($data); var_dump($_POST); print "</pre>"; This is my website: http://www.jonathonbates.info/submissions/deliver/index.php This is the XML that I should receive: <?xml version="1.0"?> <instance xmlns="http://www.devicemagic.com/xforms/**private form ID**" xmlns:dm="http://mobileforms.devicemagic.com/xforms" writeTime="2013-05-03T06:24:08-07:00" dm:submitting_user="Monk" dm:submitting_device="Android_**private ID**" dm:submit_time="2013-05-03 13:24:08 UTC" dm:form="test_form" dm:form_version="1.00"> <inputs> <test_1_not_populated>leverage real-time web services</test_1_not_populated> <test_2_populated>exploit dynamic portals</test_2_populated> <test_3_db_populated>synthesize dot-com users</test_3_db_populated> </inputs> </instance> The website that I have created is for receiving XML on a custom connection setup on a website called Device Magic - basicaly automates PUSHing forms to mobile client devices. I have set the destination (my website) within Device Magic and have only tried adding header 'Content-Type: Application/XML' as another idea. Please suggest why I receive nothing or what I could do to fix this. Many thanks
  23. Hello all, This is my very first post here and I hope someone could help me out on this as it has been a labour intensive time to try and learn all about this coding. I am trying to learn this coding using PHP and trying to do stuff myself and just through a lot of research.......I have found the holy grail of all XML feeds and this was the one feed that people who look to the main steam rankings for. Ok so I am very excited to share this with you guys and show you what I have done based on how you have educated me so far, please bear with me here: Ok the XML feed (the holy grail) is the GLOBAL USER RANKINGS, there is only one site using it now: www.aoe2stats.com They are doing what I a trying to achieve and I think I am 95% there based on what you guys have taught me through the coding, ok so here it is, I hope I still have peoples attention here. here is the link to the XML FEED: http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1 Ok, this information I am trying to extract is the following: http://steamcommunity.com/stats/Ageo...l=1&start=5001 ]]> </nextRequestURL> <resultCount>5000</resultCount> <entries> <entry> <steamid>76561198032048763</steamid> <score>689</score> <rank>1</rank> <ugcid>-1</ugcid> <details> <![CDATA[ ]]> </details> </entry> <entry> <steamid>76561198011427258</steamid> <score>632</score> <rank>2</rank> <ugcid>-1</ugcid> <details> <![CDATA[ ]]> ___________________________________________________ Into a table with 4 columns, with the names on each column: Steam Name - Score - Rank - Ugcid Now this is where I am learning also, I need to parse the (steamid) into the (community id) the steam id is the long number above and the community id is username on steam: website to show example: steamidfinder.com ok I have found a script to parse the <steamid>76561198032048763</steamid> into the person name: Huehnerbein as an example above, so I have been doing a lot of reaearching and I have found the following: _____________________________________________________________ Assuming that your input steam_id is $INPUT and your final output array is stored in $OUTPUT, this is the functional for each approach that you could use to convert steam_id to personaname: /** * Convert steam_id to personaname * @returns STRING The name associated with the given steam_id * BOOL FALSE if no match was found */ function steamID_to_name($INPUT, $OUTPUT) { // This gets the relevant part of the API response. $array = $OUTPUT['response']['players']; // Using your function to convert `steam_id` to a community ID $community_id = SteamID2CommunityID($INPUT); // Linear search foreach ($array as $array_item) { // If a match was found... if ($community_id == $array_item['steamid']) // Return the name return $array_item['personaname']; } // If no match was found, return FALSE. return false; } _________________________________________________________________ So the conclusion is the script below, unfortunately is does not work but I have tried to change the neccesary parameters in the script, so the objective is: as what www.aoe2stats.com are the only ones who have done it!! To have the 4 entries in a 4 column table: Steam Name - Score - Rank - Ugcid and to have the steamid parse into the community_id or username. OK THE ACTUAL SCRIPT I HAVE MODIFIED, IT DOES NOT WORK BUT CAN YOU GUYS SHARE WITH ME WHAT MISTAKES I HAVE MADE SO I CAN GET THIS HOLY GRAIL SCRIPT WORKING, I HAVE SPENT HOURS ON THIS: SCRIPT BELOW: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); $sFeed = 'http://steamcommunity.com/stats/AgeofEmpiresIIHDEdition/leaderboards/131879/?xml=1' . microtime(true); /** * Convert steam_id to personaname * @returns STRING The name associated with the given steam_id * BOOL FALSE if no match was found */ function steamID_to_name($INPUT, $OUTPUT) { // This gets the relevant part of the API response. $array = $OUTPUT['response']['players']; // Using your function to convert `steam_id` to a community ID $community_id = SteamID2CommunityID($INPUT); // Linear search foreach ($array as $array_item) { // If a match was found... if ($community_id == $array_item['steamid']) // Return the name return $array_item['personaname']; } // If no match was found, return FALSE. return false; } $dom = new DOMDocument('1.0', 'utf-8'); $dom->load($sFeed); $steamid = $dom->getElementsByTagName('steamid'); if ($entry->length > 0) $score = $dom->getElementsByTagName('score'); if ($entry->length > 0) $rank = $dom->getElementsByTagName('rank'); if ($entry->length > 0) $ugcid = $dom->getElementsByTagName('ugcid'); if ($entry->length > 0) { ?> <style> table, td, th body { font-family:Verdana, Arial, Helvetica; font-size: 81%; margin: 0px; color: #5c3d0b; font-weight:bold; } { border:1px solid black; } th { background-color:e6cb9c; } </style> <table border="1"> <tr> <th>NAME</th> <th>SCORE</th> <th>RANK</th> <th>UGCID</th> </tr> <? foreach ($entry AS $entry) { $steamid = $entry->getElementsByTagName('steamid')->item(0)->nodeValue; $score = $entry->getElementsByTagName('score')->item(0)->nodeValue; $rank = $entry->getElementsByTagName('rank')->item(0)->nodeValue; $ugcid = $entry->getElementsByTagName('ugcid')->item(0)->nodeValue; printf("<tr><td>%s</td><td>%s</td></tr>" . PHP_EOL, $name, $percent); } print('</table>'); } ___________________________________________________________________ OK PLEASE PLEASE GUYS WOULD LOVE TO SEE WHAT I HAVE DONE WRONG TO GET THIS SCRIPT WORKING SO MANY THANKS!!
  24. i am trying to make an update script using an xml with a login username / password authorization. i have never encountered one before one looking to see if anyone could point me in the right direction. any questions please ask matt
  25. I'm trying to pick out items from an XML file by their titles using Xpath in DOM, but because some have apostrophes, and others have quotes, it doesn't work. I've tried replacing the apostrophes using this $query1 = 'channel/item[title='.$p.']/title'; but it only works for the apostrophes, not the quotes. Any advice on how to do this? <?php $q = $_GET["q"]; $q = explode('|^', $q); $counts = count($q); unset($q[$counts-1]); $p = stripslashes($q); $q = stripslashes($p); $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->Load("../$userid.xml"); $xpath = new DOMXPath($dom); foreach ($q as $r) { $p = preg_replace("/'/","",$r); $query1 = "channel/item[title="'.$p.']/title"; $query2 = "channel/item[title="'.$p.']/url"; $query3 = "channel/item[title="'.$p.']"; $entries = $xpath->query($query1); $entries2 = $xpath->query($query2); $entries3 = $xpath->query($query3); foreach ($entries as $entry) { foreach ($entries2 as $entry2) { foreach ($entries3 as $entry3) { $oldchapter = $entry->parentNode->removeChild($entry); $oldchapter2 = $entry2->parentNode->removeChild($entry2); $oldchapter3 = $entry3->parentNode->removeChild($entry3); $dom->preserveWhiteSpace = false; } } } } $dom->formatOutput = true; $dom->save("../$userid.xml") ?> Basically, my code extracts titles from a URL, separated by "|^" (For example title1|^title2|^title3|^). Because the "|^" is appended to the end of each title, I have to remove the empty value from the array. Then, because the titles with apostrophes come in like "Title\\'s", I have to strip slashes twice to get rid of them. Then I load a new DOMdocument, and find the titles from the URL in my existing XML document. Then I want the code to remove the whole items (titles, urls and the item itself) which have the same titles as the ones in the URL, and then save the document.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.