xml() public method

XML parser, helper function.
public xml ( $payload ) : array
$payload
return array
示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $file = Request::file('xmlfile');
     $type = Input::get('type');
     $userid = Input::get('userid');
     $alpha = Input::get('alpha');
     $extension = $file->getClientOriginalExtension();
     $oname = $file->getClientOriginalName();
     Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file));
     $parser = new Parser();
     $contents = Storage::get("uploads/" . $file->getClientOriginalName());
     $rawxml = $parser->xml($contents);
     $importer = new Importer();
     if ($type == 'recipes') {
         $importer->parseRecipe($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'blocks') {
         $importer->parseBlocks($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'materials') {
         $importer->parseMaterial($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'items') {
         $importer->parseItems($rawxml, $userid, $alpha, 1);
     }
     //Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!');
     return view('pages.import');
 }
示例#2
0
 /**
  * Parse the xml document and extract the needed data
  * @method parseDocument
  * @return [type]        [description]
  */
 public function parse()
 {
     $xml_path = storage_path() . DIRECTORY_SEPARATOR . 'documents' . DIRECTORY_SEPARATOR;
     $xml_file = $this->raw_file_path;
     $xml_raw_text = file_get_contents($xml_path . $xml_file);
     $parser = new Parser();
     $this->parsed = $parser->xml($xml_raw_text);
     $this->params = ['file_name' => $this->getFileName(), 'description' => $this->getDescription(), 'file_type' => $this->getFileType(), 'geometry_type' => $this->getGeometryType(), 'attributes' => $this->getAttributes(), 'responsible_parties' => $this->getResponsibleParties(), 'construction_procedures' => $this->getContstructionProcedures(), 'coverage_area' => $this->getCoverageArea(), 'dates' => $this->getDates(), 'date_last_updated' => @$this->parsed['mdDateSt'] ?: ''];
     return $this->params;
 }
示例#3
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>XML Example</h1>";
$parsed = $parser->xml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n                        <xml>\n                            <message>\n                                <to>Jack Smith</to>\n                                <from>Jane Doe</from>\n                                <subject>Hello World</subject>\n                                <body>Hello, whats going on...</body>\n                            </message>\n                        </xml>");
echo "<pre>";
print_r($parsed);
echo "</pre>";
示例#4
0
 /** @test */
 public function throws_an_exception_when_parsed_xml_bad_data()
 {
     $parser = new Parser();
     $this->setExpectedException('Exception', 'Failed To Parse XML');
     $parser->xml('as|df>ASFBw924hg2=');
 }