Jump to content

Search the Community

Showing results for tags 'xml'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Good morning guys. I am pulling data from vehicle tracking site via soap curl. but the data format that I am getting it in is unusable, maybee i am doing something wrong. please have a look. here is the code. <?php //Data, connection, auth $dataFromTheForm = $_POST['fieldName']; // request data from the form $soapUrl = "https://fleet11.******.co.za/api/"; // asmx URL of WSDL $soapUser = "********"; // username $soapPassword = "********"; // password // xml post structure $xml_post_string = '<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="fleet11.cartrack.co.za/api/"> <soapenv:Header/> <soapenv:Body> <api:endpoint.get_vehicle_last_positions soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <username xsi:type="xsd:string">?</username> </api:endpoint.get_vehicle_last_positions> </soapenv:Body> </soapenv:Envelope>'; $headers = array( "Content-type: application/x-www-form-urlencoded", "Accept: text/xml", "Cache-Control: no-cache", "Pragma: no-cache", "SOAPAction: fleet11.******.co.za/api/#get_vehicle_last_positions", "Content-length: ".strlen($xml_post_string), ); $url = $soapUrl; // var_dump($url); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, $soapUser.":".$soapPassword); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); `curl_setopt($ch, CURLOPT_HEADER, true);` // converting $response = curl_exec($ch); curl_close($ch); //paul add //echo "<pre>"; print_r($response); What is returning is single line entries How di i get this into a format to import into mysql
  2. I stumbled upon a video in develop php, that uses php to create a dynamic xml file. I tried to use their code, and modify to my needs but I wasn't able to. I need a php file that creates an xml with all the subfolders in a folder and the images inside those subfolders. Can someone please help me get this working? Thanks. This is what I have tried so far: http://www.developphp.com/video/PHP/Image-Gallery-PHP-Loop-Files-Dynamic-XML-Tutorial <?php header("Content-Type: text/xml"); // set the content type to xml // Initialize the xmlOutput variable $xmlBody = '<?xml version="1.0" encoding="ISO-8859-1"?>'; $dir = "../images/"; // Specify Directory where images are $xmlBody .= "<XML>"; // Start XMLBody output // open specified directory using opendir() the function $dirHandle = opendir($dir); // Create incremental counter variable if needed $i = 0; $root = '../images'; $iter = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($root, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied" ); $paths = array($root); foreach ($iter as $path => $dir) { if ($dir->isDir()) { $paths[] = $path; if(!is_dir($file) && strpos($file, '.jpg')){ $i++; // increment $i by one each pass in the loop $xmlBody .= <'$paths[$iter]'>' '<'$paths[$iter]'> <picNum>' . $i . '</picNum> <picURL>' . $dir . '' . $file . '</picURL> </Picture>'; } // close the if statement } } while ($file = readdir($dirHandle)) { // if file is not a folder and if file name contains the string .jpg if(!is_dir($file) && strpos($file, '.jpg')){ $i++; // increment $i by one each pass in the loop } // close the if statement } // End while loop closedir($dirHandle); // close the open directory $xmlBody .= "</XML>"; echo $xmlBody; // output the gallery data as XML file for flash ?>
  3. Is it possible to append to cdatasection within xml file using a loop without creating a new cdata section with each loop thru. The code starts out by creating the basics for xml then enters into a loop to go thru each element of an array, appending the cdata. $xml=new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; $xml->formatOutput = true; $components = $xml->createElement("components"); $name=$xml->createAttribute("name"); $name->value = "customEPGGrid"; $extends=$xml->createAttribute("extends"); $extends->value = "EPGGrid"; $components->appendChild($name); $components->appendChild($extends); $script = $xml->createElement("script"); $type=$xml->createAttribute("type"); $type->value = "text/brightscript"; foreach ($items as $item){ //ENTER INTO LOOP $cdata=$xml->createCDATASection(<<<EOT function init() m.content = createObject("RoSGNode","ContentNode") m.top.setFocus(true) dateNow = CreateObject("roDateTime") dateNow = dateNow.asSeconds() - 2000 addChannel({$item['name']}) addItem({$item['name']}, dateNow) m.top.content = m.content m.top.translation = [50, 300] m.top.numRows = 5 m.top.duration = 10800 m.top.nowNextMode = false m.top.infoGridGap = 0 m.top.channelInfoColumnLabel = "HELLO" end function sub addChannel(channelText as string) m.channel = m.content.createChild("ContentNode") m.channel.TITLE = channelText m.channel.HDSMALLICONURL = "http://css.boshanka.co.uk/wp-content/uploads/2015/04/icon-logo-design-small.png" end sub sub addItem(progText as string, timeStart) For i=0 To 5 Step 1 program = m.channel.createChild("ContentNode") program.TITLE = progText + str(i) program.PLAYSTART = timeStart + (i * 2000) program.PLAYDURATION = "2000" End For end sub EOT ); } $script->appendChild($cdata); $script->appendChild($type); $components->appendChild($script); $xml->appendChild($components); $xml->save($filename2); When executed like this, I get a new createCDATASection with each pass thru the loop. Not really wanting this, but one createCDATASection with different value or $item['name'].
  4. I hate javascript and working with Google maps but, anyways. I am trying to update my old maps to a new style. Here is the new style. http://www.mesquiteweather.net/lsm/map.html I am trying to added the markers to the map from an XML file which is this one. http://www.mesquiteweather.net/tracker/data.xml It should look like this. http://www.mesquiteweather.net/wxspotter.php I have transferred the code over to the updated map style but, for some reason it isn't displaying the markers. Can someone please tell me what it is I am missing or doing wrong which I am sure is a lot since I am horrible with javascript. Here is the code to the updated map that I am trying to show the XML markers on. http://pastebin.com/rFVG4nJS -Thanks
  5. When you upload a file I am trying to display it in a HTML table in one column and then transform it into another file in another column automatically so you only need to upload one file instead of two. I can transform it into the same format but I don't know how to convert it to the other format when you have uploaded it. The code below transforms the XML file and displays it into the table once you have uploaded a file. This is a link to the page so you can see what it does. http://projectassignment.esy.es/project%20Assignment/test3.php The other link to the other transformed xml page is this. http://projectassignment.esy.es/project%20Assignment/cgx2.php <?php error_reporting(1); $dom = new DOMDocument('1.0', 'utf-8'); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; $name = $_FILES['file']['name']; $dom->load($name); //$cogxml = simplexml_load_file($name); $extension = strtolower(substr($name, strpos($name, '.') + 1)); #$size = $_FILES['file']['size']; # $type = $_FILES['file']['type']; $tmp_name = $_FILES['file']['tmp_name']; if (isset($name)) { if (!empty($name)) { if (($extension == 'cogxml' || $extension == 'cgx')) { $location = ''; if (move_uploaded_file($tmp_name, $location . $name)) { echo 'uploaded'; } else { echo 'There was an error'; } } else { echo 'File must be cogxml or cgx.'; } } } $newdom = new DOMDocument('1.0', 'utf-8'); $newdom->formatOutput = true; $newdom->preserveWhiteSpace = false; $xpath = new DOMXPath($dom); ?> <html> <head></head> <body> <form action="test3.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file" multiple><br><br> <input type="submit" value="Upload"> </form> <table border=1> <tr><th width='5%'>Concept Name</th><th width='5%'>Relation Type</th><th width='44%'>CoGui XML</th><th width='46%'>CharGer XML</th></tr> <?php foreach ($dom->getElementsByTagName("ctype") as $ctype) { ?> <tr><td> <?php echo $ctype->getAttribute('label') ?></td><td></td> <?php $newdom->loadXML("<cogxml><support><conceptTypes /><relationTypes /></support></cogxml>"); $newnode = $newdom->importNode($ctype, true); $newdom->getElementsByTagName("conceptTypes")->item(0)->appendChild($newnode); $id = $ctype->getAttribute('id'); foreach ($xpath->query("//cogxml/support/conceptTypes/order[@id1='$id']") as $order) { $newnode = $newdom->importNode($order, true); $newdom->getElementsByTagName("conceptTypes")->item(0)->appendChild($newnode); } foreach ($xpath->query("//cogxml/support/relationTypes/rtype[contains(@idSignature, '$id')]") as $rtype) { $newnode = $newdom->importNode($rtype, true); $newdom->getElementsByTagName("relationTypes")->item(0)->appendChild($newnode); } ?> <td><xmp><?php echo $newdom->saveXML(); ?> </xmp></td><td></td></tr><?php } ?> </table> </body> </html> $name is the file you upload. An example file is this. <?xml version="1.0" encoding="UTF-8" standalone="no"?> <cogxml> <namespace name="http://www.lirmm.fr/cogui#" prefix=""/> <support name="vocabulary"> <conceptTypes> <ctype id="http://www.lirmm.fr/cogui#ct_043ea910-5f86-4150-b0f1-1418acf4db39" label="Junior Employee" x="250" y="10"> <translation descr="" label="Junior Employee" lang="en"/> </ctype> <ctype id="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" label="Employee" x="130" y="60"> <translation descr="" label="Employee" lang="en"/> </ctype> <ctype id="http://www.lirmm.fr/cogui#ct_feeca670-2f1c-433e-9271-4cffeda1e929" label="Director" x="250" y="110"> <translation descr="" label="Director" lang="en"/> </ctype> <ctype id="http://www.lirmm.fr/cogui#ct_710bed80-a33e-4a13-b916-15fbb3357e8d" label="Manager" x="250" y="60"> <translation descr="" label="Manager" lang="en"/> </ctype> <ctype id="http://www.lirmm.fr/cogui#ct_cd84c648-ef22-4854-8e8c-a6654c0386be" label="Senior Employee" x="255" y="190"> <translation descr="" label="Senior Employee" lang="en"/> </ctype> <ctype id="http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288" label="Top" x="10" y="60"> <translation descr="" label="Top" lang="en"/> </ctype> <order id1="http://www.lirmm.fr/cogui#ct_cd84c648-ef22-4854-8e8c-a6654c0386be" id2="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00"/> <order id1="http://www.lirmm.fr/cogui#ct_feeca670-2f1c-433e-9271-4cffeda1e929" id2="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00"/> <order id1="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" id2="http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288"/> <order id1="http://www.lirmm.fr/cogui#ct_043ea910-5f86-4150-b0f1-1418acf4db39" id2="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00"/> <order id1="http://www.lirmm.fr/cogui#ct_710bed80-a33e-4a13-b916-15fbb3357e8d" id2="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00"/> </conceptTypes> <relationTypes> <rtype id="http://www.lirmm.fr/cogui#_rt_c42a5ce6-2f20-491d-8c91-501ae178a36c" idSignature="http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288 http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288" label="Link" x="10.0" y="10.0"> <translation descr="" label="Link" lang="en"/> </rtype> <rtype id="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" idSignature="http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288 http://www.lirmm.fr/cogui#_ct_a12bacc5-bc88-429e-a7b1-45e143591288" label="senior" x="70.0" y="10.0"> <translation descr="" label="senior" lang="en"/> </rtype> <order id1="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" id2="http://www.lirmm.fr/cogui#_rt_c42a5ce6-2f20-491d-8c91-501ae178a36c"/> </relationTypes> <nestingTypes> <ntype id="http://www.lirmm.fr/cogui#_nt_4d626655-02b5-496e-b19c-f4cdb72ee70a" label="Nesting"> <translation descr="" label="Nesting" lang="en"/> </ntype> </nestingTypes> <conformity> <marker id="http://www.lirmm.fr/cogui#i_435d513c-1b39-43b1-9b6d-310fa0ee46d3" idType="http://www.lirmm.fr/cogui#ct_710bed80-a33e-4a13-b916-15fbb3357e8d" label="Lucy"/> <marker id="http://www.lirmm.fr/cogui#i_80311575-7d72-4af7-bdbe-a19c4bbcf248" idType="http://www.lirmm.fr/cogui#ct_cd84c648-ef22-4854-8e8c-a6654c0386be" label="Simon"/> <marker id="http://www.lirmm.fr/cogui#i_d1a8babc-3d35-4580-b4d5-d3cd4c323c98" idType="http://www.lirmm.fr/cogui#ct_043ea910-5f86-4150-b0f1-1418acf4db39" label="Robyn"/> <marker id="http://www.lirmm.fr/cogui#i_efbef15b-d6e2-4c0a-8155-ecaae75cc673" idType="http://www.lirmm.fr/cogui#ct_feeca670-2f1c-433e-9271-4cffeda1e929" label="Richard"/> </conformity> <modules/> </support> <localeTypes name="undefined_vocabulary"> <conceptTypes/> <relationTypes/> <nestingTypes/> <conformity/> <modules/> </localeTypes> <graph id="_g1" label="seniorities" nature="fact" set="default_set"> <concept id="c_f55e1936-7842-4518-b460-bb34a9000871" idMarker="http://www.lirmm.fr/cogui#i_d1a8babc-3d35-4580-b4d5-d3cd4c323c98" idType="http://www.lirmm.fr/cogui#ct_043ea910-5f86-4150-b0f1-1418acf4db39" referent="individual" x="0" y="0"/> <concept id="c_f081c276-57ff-4650-94ec-6e40dfd38023" idMarker="http://www.lirmm.fr/cogui#i_80311575-7d72-4af7-bdbe-a19c4bbcf248" idType="http://www.lirmm.fr/cogui#ct_cd84c648-ef22-4854-8e8c-a6654c0386be" referent="individual" x="185" y="70"/> <concept id="c_f0229ed1-c913-4373-af9c-361a90a56e90" idMarker="http://www.lirmm.fr/cogui#i_435d513c-1b39-43b1-9b6d-310fa0ee46d3" idType="http://www.lirmm.fr/cogui#ct_710bed80-a33e-4a13-b916-15fbb3357e8d" referent="individual" x="330" y="170"/> <concept id="c_dbe5b7cb-7d00-44f1-8b9a-832d5b61a126" idMarker="http://www.lirmm.fr/cogui#i_efbef15b-d6e2-4c0a-8155-ecaae75cc673" idType="http://www.lirmm.fr/cogui#ct_feeca670-2f1c-433e-9271-4cffeda1e929" referent="individual" x="445" y="260"/> <relation id="r_10008dd3-5426-4c87-8651-049045f98376" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="90" y="70"/> <relation id="r_8ef0b4bf-3cb6-4dde-9c83-903cb459872a" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="235" y="135"/> <relation id="r_563d1804-04eb-45d4-81c9-f4bd4782e0b1" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="355" y="260"/> <edge cid="c_f55e1936-7842-4518-b460-bb34a9000871" label="1" rid="r_10008dd3-5426-4c87-8651-049045f98376"/> <edge cid="c_f081c276-57ff-4650-94ec-6e40dfd38023" label="2" rid="r_10008dd3-5426-4c87-8651-049045f98376"/> <edge cid="c_f081c276-57ff-4650-94ec-6e40dfd38023" label="1" rid="r_8ef0b4bf-3cb6-4dde-9c83-903cb459872a"/> <edge cid="c_f0229ed1-c913-4373-af9c-361a90a56e90" label="2" rid="r_8ef0b4bf-3cb6-4dde-9c83-903cb459872a"/> <edge cid="c_f0229ed1-c913-4373-af9c-361a90a56e90" label="1" rid="r_563d1804-04eb-45d4-81c9-f4bd4782e0b1"/> <edge cid="c_dbe5b7cb-7d00-44f1-8b9a-832d5b61a126" label="2" rid="r_563d1804-04eb-45d4-81c9-f4bd4782e0b1"/> </graph> <graph id="_query1" label="Richard senior to Robyn" nature="query" set="default_set"> <concept id="c_90dc1159-1d02-4707-a444-2e95817d8667" idMarker="http://www.lirmm.fr/cogui#i_d1a8babc-3d35-4580-b4d5-d3cd4c323c98" idType="http://www.lirmm.fr/cogui#ct_043ea910-5f86-4150-b0f1-1418acf4db39" referent="individual" x="30" y="165"/> <concept id="c_4af4cf1c-5383-413b-bee2-7a4c513fd37e" idMarker="http://www.lirmm.fr/cogui#i_efbef15b-d6e2-4c0a-8155-ecaae75cc673" idType="http://www.lirmm.fr/cogui#ct_feeca670-2f1c-433e-9271-4cffeda1e929" referent="individual" x="45" y="25"/> <relation id="r_c51c5a9c-3cf5-4402-a356-03c9882f6b78" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="75" y="95"/> <edge cid="c_90dc1159-1d02-4707-a444-2e95817d8667" label="1" rid="r_c51c5a9c-3cf5-4402-a356-03c9882f6b78"/> <edge cid="c_4af4cf1c-5383-413b-bee2-7a4c513fd37e" label="2" rid="r_c51c5a9c-3cf5-4402-a356-03c9882f6b78"/> </graph> <rule id="_rule1"> <hypt> <graph id="_rule1_hypt" label="seniority rule" nature="rule" set="default_set"> <concept id="c_591883b6-ca82-42ee-bd35-b4ce29ffd286" idType="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" x="30" y="45"/> <concept id="c_f765dff9-1cd4-42f1-bf95-87cbda00257d" idType="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" x="30" y="173"/> <concept id="c_669f89c9-eb93-4caa-aa90-f8e31be92245" idType="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" x="30" y="293"/> <relation id="r_93ecba23-873d-490c-8ce3-40611158006b" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="45" y="113"/> <relation id="r_257f3815-2ac4-4b9e-8b8c-7d9ae6259b52" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="53" y="233"/> <edge cid="c_591883b6-ca82-42ee-bd35-b4ce29ffd286" label="1" rid="r_93ecba23-873d-490c-8ce3-40611158006b"/> <edge cid="c_f765dff9-1cd4-42f1-bf95-87cbda00257d" label="2" rid="r_93ecba23-873d-490c-8ce3-40611158006b"/> <edge cid="c_f765dff9-1cd4-42f1-bf95-87cbda00257d" label="1" rid="r_257f3815-2ac4-4b9e-8b8c-7d9ae6259b52"/> <edge cid="c_669f89c9-eb93-4caa-aa90-f8e31be92245" label="2" rid="r_257f3815-2ac4-4b9e-8b8c-7d9ae6259b52"/> </graph> </hypt> <conc> <graph id="_rule1_conc"> <concept id="c_fe469224-c26a-49dc-a17a-697faa20aca3" idType="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" x="173" y="53"/> <concept id="c_656473af-5b41-4ed7-b4fc-be3af9ce544d" idType="http://www.lirmm.fr/cogui#ct_d7a78641-722f-4609-8f5a-90affc111e00" x="180" y="293"/> <relation id="r_3b36e657-bc62-4050-baad-c3a04ade3af2" idType="http://www.lirmm.fr/cogui#rt_af40394c-9e62-4e92-b05b-352de5db876f" x="203" y="158"/> <edge cid="c_fe469224-c26a-49dc-a17a-697faa20aca3" label="1" rid="r_3b36e657-bc62-4050-baad-c3a04ade3af2"/> <edge cid="c_656473af-5b41-4ed7-b4fc-be3af9ce544d" label="2" rid="r_3b36e657-bc62-4050-baad-c3a04ade3af2"/> </graph> </conc> <conPts> <couple idC1="c_591883b6-ca82-42ee-bd35-b4ce29ffd286" idC2="c_fe469224-c26a-49dc-a17a-697faa20aca3"/> <couple idC1="c_669f89c9-eb93-4caa-aa90-f8e31be92245" idC2="c_656473af-5b41-4ed7-b4fc-be3af9ce544d"/> </conPts> </rule> </cogxml> The other transformed php file looks like this. <?php error_reporting(1); $dom = new DOMDocument('1.0', 'utf-8'); $dom->formatOutput = true; $dom->preserveWhiteSpace = false; $name = $_FILES['file']['name']; $dom->load($name); $extension = strtolower(substr($name, strpos($name, '.') + 1)); #$size = $_FILES['file']['size']; # $type = $_FILES['file']['type']; $tmp_name = $_FILES['file']['tmp_name']; if (isset($name)) { if (!empty($name)) { if (($extension == 'cogxml' || $extension == 'cgx')) { $location = ''; if (move_uploaded_file($tmp_name, $location . $name)) { echo 'uploaded'; } else { echo 'There was an error'; } } else { echo 'File must be cogxml or cgx.'; } } } $newdom = new DOMDocument('1.0', 'utf-8'); $newdom->formatOutput = true; $newdom->preserveWhiteSpace = false; $xpath = new DOMXPath($dom); ?> <html> <head> <title>Parsing CharGer and CoGui</title> <link rel="stylesheet" type="text/css" href="myStyle.css" /> </head> <body> <form action="cgx2.php" method="POST" enctype="multipart/form-data"> <input type="file" name="file"><br><br> <input type="submit" value="Submit"> </form> <?php echo "<table border=1> <tr><th width='5%'>Concept Name</th><th width='5%'>Relation Type</th><th width='44%'>CoGui XML</th><th width='46%'>CharGer XML</th></tr>"; foreach ($dom->getElementsByTagName("concept") as $concept) { echo '<tr><td></td><td>' . $concept->getAttribute('label') . '</td><td></td>'; $newdom->loadXML("<conceptualgraph><graph><concept /><relation /></graph></conceptualgraph>"); $newnode = $newdom->importNode($concept, true); $newdom->getElementsByTagName("concept")->item(0)->appendChild($newnode); $id = $concept->getAttribute('id'); foreach ($xpath->query("//conceptualgraph/graph/relation[contains(@owner, '$id')]") as $rtype) { $newnode = $newdom->importNode($rtype, true); $newdom->getElementsByTagName("relation")->item(0)->appendChild($newnode); } echo '<td><xmp>' . $newdom->saveXML() . '</xmp></td><td></td></tr>'; } echo '</table>'; ?> </body> </html> An example of the file you upload would be this. <?xml version="1.0" encoding="UTF-8"?> <conceptualgraph editor="CharGer" version="4.1.0" created="Jan 4, 2016 12:06:58 AM" modified="Jan 4, 2016 12:36:07 AM" user="Charli" wrapLabels="false" wrapColumns="30"> <graph id="401e8946:15209f3d481:-7fd9" owner="0"> <type> <label>Proposition</label> </type> <layout> <rectangle x="5.00" y="5.00" width="1200.00" height="900.00"/> <color foreground="0,94,192" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> <relation id="401e8946:15209f3d481:-7f98" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Child Of Adult</label> </type> <layout> <rectangle x="341.00" y="114.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fcc" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Parent Of Child</label> </type> <layout> <rectangle x="172.00" y="70.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7faa" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Mother Of Child</label> </type> <layout> <rectangle x="317.00" y="310.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fa0" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Gender Of Child</label> </type> <layout> <rectangle x="278.00" y="270.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <relation id="401e8946:15209f3d481:-7fc5" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Gender of Adult</label> </type> <layout> <rectangle x="79.00" y="218.00" width="40.00" height="24.00"/> <color foreground="0,0,0" background="255,231,100"/> <font name="SansSerif" style="1" size="12" /> </layout> </relation> <concept id="401e8946:15209f3d481:-7fd4" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Girl</label> </type> <layout> <rectangle x="92.00" y="298.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd5" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Female</label> </type> <layout> <rectangle x="358.50" y="201.00" width="49.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fb3" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Woman</label> </type> <layout> <rectangle x="148.00" y="262.00" width="52.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd6" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Adult</label> </type> <layout> <rectangle x="162.00" y="129.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd7" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Child</label> </type> <layout> <rectangle x="37.00" y="148.00" width="40.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <concept id="401e8946:15209f3d481:-7fd8" owner="401e8946:15209f3d481:-7fd9"> <type> <label>Human</label> </type> <layout> <rectangle x="181.00" y="11.00" width="48.00" height="30.00"/> <color foreground="255,255,255" background="0,94,192"/> <font name="SansSerif" style="1" size="12" /> </layout> </concept> <arrow id="401e8946:15209f3d481:-7f96" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f98" to="401e8946:15209f3d481:-7fbb"> <layout> <rectangle x="396.48" y="128.66" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fca" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fcc" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="193.77" y="53.12" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f97" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9b" to="401e8946:15209f3d481:-7f98"> <layout> <rectangle x="314.23" y="169.88" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fcb" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd6" to="401e8946:15209f3d481:-7fcc"> <layout> <rectangle x="183.48" y="106.05" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f99" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9c" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="207.00" y="160.54" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fab" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb0" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="274.59" y="47.60" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fac" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fbb" to="401e8946:15209f3d481:-7fb0"> <layout> <rectangle x="384.85" y="99.96" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fad" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb2" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="235.08" y="53.19" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fae" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd5" to="401e8946:15209f3d481:-7fb2"> <layout> <rectangle x="316.05" y="140.06" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc2" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc5" to="401e8946:15209f3d481:-7fd7"> <layout> <rectangle x="76.19" y="195.99" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc3" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd4" to="401e8946:15209f3d481:-7fc5"> <layout> <rectangle x="101.07" y="264.73" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa1" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa3" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="165.23" y="172.76" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa2" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb3" to="401e8946:15209f3d481:-7fa3"> <layout> <rectangle x="161.91" y="233.11" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa4" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa7" to="401e8946:15209f3d481:-7fbb"> <layout> <rectangle x="414.30" y="251.12" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc7" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc9" to="401e8946:15209f3d481:-7fd6"> <layout> <rectangle x="140.08" y="113.96" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa5" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc1" to="401e8946:15209f3d481:-7fa7"> <layout> <rectangle x="224.84" y="350.58" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fc8" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd7" to="401e8946:15209f3d481:-7fc9"> <layout> <rectangle x="85.27" y="122.84" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa8" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7faa" to="401e8946:15209f3d481:-7fd5"> <layout> <rectangle x="354.68" y="268.04" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fa9" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd4" to="401e8946:15209f3d481:-7faa"> <layout> <rectangle x="222.14" y="313.57" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fbc" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fbf" to="401e8946:15209f3d481:-7fd7"> <layout> <rectangle x="49.28" y="211.56" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fbd" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fc1" to="401e8946:15209f3d481:-7fbf"> <layout> <rectangle x="51.13" y="296.73" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9a" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7f9b" to="401e8946:15209f3d481:-7f9c"> <layout> <rectangle x="242.69" y="195.83" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9d" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fa0" to="401e8946:15209f3d481:-7fd5"> <layout> <rectangle x="330.90" y="249.35" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7f9e" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb3" to="401e8946:15209f3d481:-7fa0"> <layout> <rectangle x="236.58" y="275.68" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fb4" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fb7" to="401e8946:15209f3d481:-7fd8"> <layout> <rectangle x="131.39" y="43.42" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> <arrow id="401e8946:15209f3d481:-7fb5" owner="401e8946:15209f3d481:-7fd9" label="-" from="401e8946:15209f3d481:-7fd7" to="401e8946:15209f3d481:-7fb7"> <layout> <rectangle x="62.59" y="107.31" width="8.00" height="8.00"/> <color foreground="0,0,0" background="255,255,255"/> <font name="SansSerif" style="1" size="12" /> <edge arrowHeadWidth="5" arrowHeadHeight="5" edgeThickness="1.5" /> </layout> </arrow> </graph> </conceptualgraph>
  6. I am trying to read an RSS feed and the way my code is written, it is only repeating the first result. the xml looks like this: <?xml version="1.0" encoding="ISO-8859-1" ?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Latest Filings - Thu, 18 Feb 2016 14:52:36 EST</title> <link rel="alternate" href="/cgi-bin/browse-edgar?action=getcurrent"/> <link rel="self" href="/cgi-bin/browse-edgar?action=getcurrent"/> <id>http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent</id> <author><name>Webmaster</name><email>webmaster@sec.gov</email></author> <updated>2016-02-18T14:52:36-05:00</updated> <entry> <title>4 - YABUKI JEFFERY W (0001207371) (Reporting)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/1207371/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> </entry> <entry> <title>4 - FISERV INC (0000798354) (Issuer)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/798354/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> and my code is like this: $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $url = 'http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent&CIK=&type=4&company=&dateb=&owner=include&start=100&count=20&output=atom'; $xml = file_get_contents($url, false,$context); $xml = simplexml_load_string($xml); print_r($xml); foreach ($xml->entry as $entry){ $FnumI=$xml->entry->title; //$FnumC=$xml->entry->title; $Fdate=$xml->entry->updated; $Flink=$xml->entry->link->attributes()->href; $Form=$xml->entry->category->attributes()->term; echo "<tr>"; echo "<td><p>".$FnumI."</p></td>"; //echo "<td><p>".$FnumC."</p></td>"; echo "<td><p>".$Fdate."</p></td>"; echo "<td><p><a href='".$Flink."'> ". $Flink."</p></td>"; echo "<td><p>".$Form."</p></td>"; echo "</tr>"; }
  7. Hello I would like to populate the select onload. or document ready with jquery I dont see why not working' <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>xml to select</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script> $(document).ready(function() { $.ajax({ type: "GET", url: "test.xml", dataType: "xml", success: function(xml) { $("#myDiv").append("<select id='mySelect'>"); $(xml).find('value').each(function(){ var a = $(this).text(); $("#mySelect").append("<option class='nice' value='" + a + "'>" + a + "</option>"); }); $("#myDiv").append("</select>"); } }); }</script> </head> <body> <div id="myDiv"></div> </body> </html> Thank you for your advice.
  8. Hello... I want to calculate the value from 2 difference files using simplexml load file... But the result not as expected.. My output should be 7 and 5 where 10 - 7 and 8 - 3. My first xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>10</value> </item> <item> <q_id>4232002</q_id> <value>8</value> </item> </items> My second xml files. <?xml version="1.0" encoding="UTF-8"?> <items> <item> <q_id>4131001</q_id> <value>7</value> </item> <item> <q_id>4232002</q_id> <value>3</value> </item> </items> My scripts. <?php $xml = simplexml_load_file('q1.xml'); $xml2 = simplexml_load_file('q2.xml'); foreach ($xml -> item as $item) { $value1 = $item->value; echo $item->q_id.'<br />'; //echo $value1.'<br />'; foreach ($xml2 -> item as $item2) { $value2 = $item2->value; $total = $value1 - $value2; echo $total.'<br />'; } } ?> The result should be 7 and 5 where 10 - 7 and 8 - 3 but there is another unknows value which is 3 and 1... How to solve the issue.. Thank for any help..
  9. I tried to solve problem, but without success, so I am here to seek for some help. I have folder on web server, that contains subfolders and pdf files. I need PHP script that monitors folder and subfolders and create XML for RSS feed on site homepage whe new files are added to folders. Site is on local network only, it is not accesible via Internet. I tried number of scripts but without success. Any advice please?
  10. Hi.. I really need help. I'm completely stuck and waaaay out of my depth here. I don't even know where to begin. I am desperate to learn how to use existing API services - but I find the whole concept completely overwhelming. I can't even get something from a Google search because everything on this subject just goes over my head. I have created an account with tvrage.com and got an API key. With that, I can get a list, in XML, of all the current TV shows in the UK and the US. It starts like this; <currentshows> <country name="US"> <show> <showid>69</showid> <showname>Who Wants to Be a Millionaire (US)</showname> <showlink>http://tvrage.com/Who_Wants_to_Be_a_Millionaire_US</showlink> </show> <show> <showid>237</showid> <showname>Jack Van Impe</showname> <showlink>http://tvrage.com/jack-van-impe</showlink> </show> <show> <showid>286</showid> <showname>Figure It Out</showname> <showlink>http://tvrage.com/figure-it-out</showlink> </show> <show> <showid>548</showid> <showname>TNA Pay-Per-View</showname> <showlink>http://tvrage.com/TNA_Pay-Per-View</showlink> </show> <show> <showid>576</showid> <showname>WWE After Burn</showname> <showlink>http://tvrage.com/wwe-after-burn</showlink> </show> All I want, is to list this out on MY website... I am a complete beginner. I imagine I have to copy and paste the URL in to my code, right? A javascript link? But then, what after that? I have barely touched javascript or jquery as a developer. Can someone just give me some guidance on this please? It's really starting to stress me out :-(
  11. Hello i need help to make a product display page from xml file .... any one who can help me thanks i got an xml file products.xml <PRODUCT> <PRODUCTS_NAME>Name of the product</PRODUCTS_NAME> <PRODUCTS_DESCRIPTION>Details of the products.</PRODUCTS_DESCRIPTION> <PRODUCTS_IMAGE>1111.jpg</PRODUCTS_IMAGE> <PRODUCTS_PRICE>44$</PRODUCTS_PRICE> </PRODUCT> ok i used this code to get information of all the product name on the page <?php $xml=simplexml_load_file("products.xml") or die("Error: Cannot create object"); foreach($xml->children() as $products) { echo $products->PRODUCTS_NAME. "<br>"; } ?> its show all product name line by line ok so all i want to show full product one by one ... For example ( Product image | then product name | Then product price | Then product details ) Thanks for your help in advanced waiting for your answers
  12. We have a wordpress install with the plugin wp-job manager installed. https://wpjobmanager.com We add and manage jobs via YouRecruit but we want to update them to our wordpress database (wp-job manager) every time they're added, updated or we deleted. We also have a plugin/api module from YouRecruit which extends the wp job manager plugin and enables us to post and delete jobs to wp-job manager using xml. This is all the documentation I have on the API module from YouRecruit below and there are no settings in the back end of wordpress for you to fill in. Based on what I have read below I am assuming the plugin handles most of the processing but you still have to write your own PHP script and host it at 'http://www.yoursite.com/jobload/get_job.php' for example. At least this is what it says. I'm thinking were going to have to fetch the xml with simple_xml there is a brief code snipped in the documentation on doing this. I then don't know where to go from there or if this is the correct way to go about dealing with this issue. http://yourecruit.com/resources_public/wordpress_job_manager_api.php http://yourecruit.com/resources_public/own_site_posting.php Could anyone confirm if I am thinking along the right lines here. Thanks your advice is very much appreciated.
  13. I have an application that loads several xml files, and then outputs some of the data from the file. The problem is that every once in a while, the service that provides the xml file does maintenance (or has an error in the file), and my application gives a "Fatal error: Call to a member function children() on a non-object in..." I would like to handle the error differently, by displaying "unavailable" instead of the error. I know that this is usually not the appropriate way of handling errors, because there is a reason for a fatal error. Any ideas on how to appropriately handle this error? // Node 217 (GGB) $xml = simplexml_load_file("http://services.my511.org/traffic/API_KEY_REMOVED_FOR_EXAMPLE"); foreach($xml->children() as $traveltime) { $ggb = "$traveltime->currentTravelTime"; } ​echo "GGB:" , $ggb , " Minutes";
  14. Hi! I need to make a little signup form that contains 2 textbox for name and birthday and 2 buttons for submit and export to xml. When the user clicks on the export to xml button, there must be an xml file containing the information entered by the user that can be downloaded. I'm not really familiar to php but can you give me an idea on how to make this possible ? thank you in advance
  15. XSD <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:simpleType name="MgmtCodetyp"> <xsd:restriction base="xsd:string"> <xsd:pattern value="[A-Z][A-Z]([A-Z]|[0-9])"></xsd:pattern> </xsd:restriction> </xsd:simpleType> <xsd:element name="MgmtCode" type="MgmtCodetyp"></xsd:element> </xsd:schema> XML <MgmtCode>AGF</MgmtCode> PHP Code <?php $file = "data.xml"; function libxml_display_error($error) { $return = "\n"; switch ($error->level) { case LIBXML_ERR_ERROR: $return .= "[ERROR] "; break; case LIBXML_ERR_FATAL: $return .= "[FATAL] "; break; default: $return .= "[uNKNOWN] "; } $return .= trim($error->message); $return .= " [line: $error->line]\n"; return $return; } function libxml_display_errors() { $errors = libxml_get_errors(); foreach ($errors as $error) { if ($error -> level != LIBXML_ERR_WARNING) { print libxml_display_error($error); } } libxml_clear_errors(); } // Enable user error handling libxml_use_internal_errors(true); $xml = new DOMDocument; $xml -> load("kkk.xml"); if (!$xml -> schemaValidate("kkk.xsd")) { libxml_display_errors(); } else { print "no error\n"; } ?> OUTPUT [ERROR] Element 'MgmtCode': [facet 'pattern'] The value 'AGF' is not accepted by the pattern '[A-Z][A-Z]([A-Z]|[0-9])'. [line: 1] [ERROR] Element 'MgmtCode': 'AGF' is not a valid value of the atomic type 'MgmtCodetyp'. [line: 1] ANALYSIS The XML is a perfectly valid xml. I don't understand why it failed the XSD.
  16. Hi all, I have quite a big issue regarding an e-commerce site I'm in the process of redeveloping. The company whom I work for sell hundreds of event tickets to clients worldwide. I've been tasked with rebuilding the entire shop as its very basic at the moment, and only accepts PP express. The shop itself only has a few categories so the design / layout isn't a problem for me. The main issue is with the dev site of things. They want me to integrate a so-called 'white label' or 'affiliate' type system so that other 'agencies' can register with ourselves. From there they would have access to our product list and be able to add them on their own shop. In turn they would receive a commission for every sale. I was thinking about going with Prestashop or Drupal but this kind ingratiation has me thinking if its even possible. I'm not even sure if there are any off-the-self solutions that would do exactly what we need, without hiring a developer.. anyone here have any experience building a similar system? Any guidance of any of this would be greatly appreciated. Thanks 4T7
  17. Hi, I want to use an external rss in my site but the problem is that i only want to grab feeds that contain certain keywords in the title, This is what i got so far to display the feed: <?php $html = ""; $url = "http://www.feedsite.com/conv-rss.asp"; $xml = simplexml_load_file($url); for($i = 0; $i < 5; $i++){ $title = $xml->channel->item[$i]->title; $link = $xml->channel->item[$i]->link; $description = $xml->channel->item[$i]->description; $pubDate = $xml->channel->item[$i]->pubDate; $html .= "<a href='$link'><h3>$title</h3></a>"; $html .= "$description"; $html .= "<br />$pubDate<hr />"; } echo $html; ?> The feed is a classified jobs but i only need the jobs listed for musicians, keywords could be: bassist, singer, drummer, musician, etc.. Thanks
  18. I am being sent an XML feed which needs to be downloaded in a 'compressed way'. The example I have been given is this: $url = 'http://myurl.com'; $headers[] = "Accept-Encoding: gzip,deflate"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_BINARYTRANSFER, true); $data = curl_exec($ch); but the output I am getting is jargon like this with loads of black diamond question marks:� +T��sƒ���-}#v���]K���������HB�$&G�����Y�����'߷s�,�.4֫'?'���9;*9^��>�j~�ǫ}z|hq�J��Գ".o2)~b​���U~I| How to a convert it back into XML? Many thanks
  19. Hi I'm looking for some advice on how to parse an xml feed and display any odds on my site Here is an example http://feed.youwincdn.com/web/xml/en/youwin_football.xml and as you can see it is quite large so calling it every time would have an impact on the server. I am looking at using many different feeds in the future so want to start this properly and in a scaleable way. I want to use php but open to any ideas on the best way to do this Many thanks Sam
  20. I have the following code below: <?php $xml = '<Divisions xmlns="urn:description7a.services.chrome.com"> <responseStatus responseCode="Successful" description="Successful"/> <division id="1">Acura</division> <division id="44">Aston Martin</division> <division id="4">Audi</division> <division id="45">Bentley</division> <division id="5">BMW</division> <division id="6">Buick</division> <division id="7">Cadillac</division> <division id="8">Chevrolet</division> <division id="9">Chrysler</division> <division id="11">Dodge</division> <division id="46">Ferrari</division> <division id="59">FIAT</division> <division id="13">Ford</division> <division id="170">Freightliner</division> <division id="15">GMC</division> <division id="16">Honda</division> <division id="17">Hyundai</division> <division id="18">Infiniti</division> <division id="19">Isuzu</division> <division id="20">Jaguar</division> <division id="21">Jeep</division> <division id="22">Kia</division> <division id="47">Lamborghini</division> <division id="23">Land Rover</division> <division id="24">Lexus</division> <division id="25">Lincoln</division> <division id="48">Lotus</division> <division id="53">Maserati</division> <division id="26">Mazda</division> <division id="61">McLaren</division> <division id="27">Mercedes-Benz</division> <division id="2">MINI</division> <division id="29">Mitsubishi</division> <division id="30">Nissan</division> <division id="34">Porsche</division> <division id="57">Ram</division> <division id="49">Rolls-Royce</division> <division id="52">Scion</division> <division id="42">Smart</division> <division id="37">Subaru</division> <division id="56">Tesla</division> <division id="39">Toyota</division> <division id="40">Volkswagen</division> <division id="41">Volvo</division> </Divisions> '; $parse = simplexml_load_string($xml); print_r($parse); The problem is is that it's not keeping the attribute values in the xml like <division id="1">Acura</division> <division id="44">Aston Martin</division> The PHP is erasing it to be like: array ( 0 => 'Acura', 1 => 'Aston Martin' ); I'm passing this to JSON so I need it to stay in the format of an array, but need the indexes to be the value of the division ID attribute. This is what it's exactly outputting right now: SimpleXMLElement Object ( [responseStatus] => SimpleXMLElement Object ( [@attributes] => Array ( [responseCode] => Successful [description] => Successful ) ) [division] => Array ( [0] => Acura [1] => Aston Martin [2] => Audi [3] => Bentley [4] => BMW [5] => Buick [6] => Cadillac [7] => Chevrolet [8] => Chrysler [9] => Dodge [10] => Ferrari [11] => FIAT [12] => Ford [13] => Freightliner [14] => GMC [15] => Honda [16] => Hyundai [17] => Infiniti [18] => Isuzu [19] => Jaguar [20] => Jeep [21] => Kia [22] => Lamborghini [23] => Land Rover [24] => Lexus [25] => Lincoln [26] => Lotus [27] => Maserati [28] => Mazda [29] => McLaren [30] => Mercedes-Benz [31] => MINI [32] => Mitsubishi [33] => Nissan [34] => Porsche [35] => Ram [36] => Rolls-Royce [37] => Scion [38] => Smart [39] => Subaru [40] => Tesla [41] => Toyota [42] => Volkswagen [43] => Volvo ) ) Thank you for any help!
  21. Hey guys. I just recently started learning php and I like to learn hands on. So, my first project involves the Google Calendar. I found a script on github that is basically a Google calendar feed and I've been manipulating it to meet my personal needs and expectations, but the only thing I am struggling with is the xml part. All I want to do in this case is get the value from ###TITLE### (after it is sorted by newest date which is done automatically in the script) and store it in a new variable but no matter what I try or do and after reading a bunch of material on xml and php, I still cannot get it to work. If anyone knows how to do this and provide an explanation so I can actually learn I would really really appreciate it. Here is the github script https://github.com/media-uk/GCalPHP/blob/master/gcalphp.php Thank you and I am looking forward to any suggestions or anything.
  22. I have the code below , and when I run it on my website , it returns a XML Parsing Error: not well-formed error , which says it has a problem reading the & i think please see http://www.jamesflowersreports.com/php/xml2.php I think it has something to wiht the str_replace as when I change the $row['customerName'] . "</Name>\n"; to $row['customerNumber'] . "</Name>\n"; as a test it works fine , I understand XML cant handle special characters , how would prevent this happening? code as below $query = "SELECT * FROM customers"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<entries>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<entry>\n"; $xml_output .= "\t\t<Name>" . $row['customerName'] . "</Name>\n"; // Escaping illegal characters $row['text'] = str_replace("&", "&", $row['text']); $row['text'] = str_replace("<", "&lt", $row['text']); $row['text'] = str_replace(">", ">", $row['text']); $row['text'] = str_replace("\"", """, $row['text']); $xml_output.= "\t\t<Number>" . $row['customerNumber'] . "</Number>\n"; $xml_output.= "\t</entry>\n"; } $xml_output .= "</entries>"; echo $xml_output; regards James
  23. Hello. I am getting an error message: Sablotron: There was an error that occurred in the XSL transformation...127 whenever i click on the link on the home page. The website is www.aginskyconsulting.com . The home page opens fine, and then when we click on English, this is the error that happens. Any help would be appreciated. thanks
  24. Hello I want to know to upload the XML file to mysql using php as i am new to xml any help appreciated. awaiting your valuable reply here also i am attaching the xml file which i want to upload Thanks in Advance xml1.xml
  25. I'm trying to utilize a PHP script to parse a large XML file (around 450 MB) to MYSQL database into certain structure and definitions of included XML elements. The problem is that the original script uses file_get_contents and SimpleXMLElement to get it done, but the corn job executed by the server halts due to the volume of the XML file. I'm no PHP expert, so I bought this XMLSplit software and divided the XML into 17 separated XML files each at size of 30 MB, parsed them one by one using the same script. However, the output database was missing a lot of input, and I have serious doubts whether this would be the same output of the original file if left not divided automatically and parsed one by one. So, I've decided to use XMLReader with this exact PHP script to parse this big XML file, but so far I couldn't manage to simply replace the parsing code and keep other functionality intact. I'm including the script below, I'd really appreciate if someone helps me to do so. <?php set_time_limit(0); ini_set('memory_limit', '1024M'); include_once('../db.php'); include_once(DOC_ROOT.'/include/func.php'); mysql_query("TRUNCATE screenshots_list"); mysql_query("TRUNCATE pages"); mysql_query("TRUNCATE page_screenshots"); // This is the part I need help with to change into XMLReader instead of utilized function, to enable parsing of the large XML file correctly (while keeping rest of the script code as is if possible): $xmlstr = file_get_contents('t_info.xml'); $xml = new SimpleXMLElement($xmlstr); foreach ($xml->template as $item) { //print_r($item); $sql = sprintf("REPLACE INTO templates SET id = %d, state = %d, price = %d, exc_price = %d, inserted_date = '%s', update_date = '%s', downloads = %d, type_id = %d, type_name = '%s', is_flash = %d, is_adult = %d, width = '%s', author_id = %d, author_nick = '%s', package_id = %d, is_full_site = %d, is_real_size = %d, keywords = '%s', sources = '%s', description = '%s', software_required = '%s'", $item->id, $item->state, $item->price, $item->exc_price, $item->inserted_date, $item->update_date, $item->downloads, $item->template_type->type_id, $item->template_type->type_name, $item->is_flash, $item->is_adult, $item->width, $item->author->author_id, $item->author->author_nick, $item->package->package_id, $item->is_full_site, $item->is_real_size, $item->keywords, $item->sources, $item->description, $item->software_required); //echo '<br>'.$sql; mysql_query($sql); //print_r($item->screenshots_list->screenshot); foreach ($item->screenshots_list->screenshot as $scr) { $main = (!empty($scr->main_preview)) ? 1 : 0; $small = (!empty($scr->small_preview)) ? 1 : 0; insert_data($item->id, 'screenshots_list', 0, $scr->uri, $scr->filemtime, $main, $small); } foreach ($item->styles->style as $st) { insert_data($item->id, 'styles', $st->style_id, $st->style_name); } foreach ($item->categories->category as $cat) { insert_data($item->id, 'categories', $cat->category_id, $cat->category_name); } foreach ($item->sources_available_list->source as $so) { insert_data($item->id, 'sources_available_list', $so->source_id, ''); } foreach ($item->software_required_list->software as $soft) { insert_data($item->id, 'software_required_list', $soft->software_id, ''); } //print_r($item->pages->page); if (!empty($item->pages->page)) { foreach ($item->pages->page as $p) { mysql_query(sprintf("REPLACE INTO pages SET tpl_id = %d, name = '%s', id = NULL ", $item->id, $p->name)); $page_id = mysql_insert_id(); if (!empty($p->screenshots->scr)) { foreach ($p->screenshots->scr as $psc) { $href = (!empty($psc->href)) ? (string)$psc->href : ''; mysql_query(sprintf("REPLACE INTO page_screenshots SET page_id = %d, description = '%s', uri = '%s', scr_type_id = %d, width = %d, height = %d, href = '%s'", $page_id, $psc->description, $psc->uri, $psc->scr_type_id, $psc->width, $psc->height, $href)); } } } }}?> I'd appreciate your help with that...
×
×
  • 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.