I am trying to load xml content from a URL containing about 60MB of data. When I do that using simple XML built in library I keep getting the following error:
PHP Warning: DOMDocument::loadXML(): internal error: Huge input lookup in Entity, line: 845125
And the script is being stopped. What's wrong? How can I deal with this?
Sample url I use:
http://foo.com/feed.xml
Related
I'm using library PDFparser (https://github.com/smalot/pdfparser) to convert PDF file to text.
When I try to convert a file on a local web-server, it parses OK. When I try to convert a file on remote web-server, it fails with the following error: TCPDF_PARSER ERROR: Invalid object reference: Array.
I couldn't find a proper solution in the bug-tracker of a library, although there is exist the similar question (it didn't solved for two years).
How can I avoid this error? Or should I use another library for converting pdf to text (which)?
I am using it straight as mentioned in documentation:
use Smalot\PdfParser\Parser;
$this->parser = new Parser;
if (file_exists($full_path) && !is_dir($full_path)) {
$paper->text = $this->parser->parseFile($full_path)->getText();
}
I'm trying to echo out an XML File via a PHP File. Like so:
Url visits viewxml.php?id=1
Php open a specific XML file, such as "xmlfile_".$_GET['id'].".xml" and prints it as if they are visiting the xml file itself.
The reason I'm using PHP is to do Session checks to make sure they are allowed to view the xml file.
This is how I am doing this:
header("Content-type: text/xml; charset=utf-8");
// send the saved XML file.
include "xmlfile_".$id.".xml";
Doing this gives me the following GC XML error:
And there is nothing below it.
I have tried different approaches, such as printing it or turning it into a string but then I have problems reading the XML on certain software. I am hoping one of you can help me.
Thanks!
include() will attempt to evaluate the file; if there's something in there that looks like PHP then it will corrupt your results.
Try using readfile instead; this will only output the file contents.
Hi I have one file where I'm using file_get_contents to get another php file - the target file should run some php and output an HTML table, which it does if I just load it in the browser, however when I use file_get_contents to retrieve it, the php code is retrieved, not the html table.
Should I be using something different than file_get_contents?
What should I be using?
use include("filename.php") instead of file_get_contents
file_get_contents is for jut returning the contents of a file.
I am validating a SVG document (which I believe to be valid) against the SVG spec. I'm using XMLReader in PHP, and would rather stick with that as I will be using XMLReader elsewhere; that said if there are other stream-based readers that will do this easier/better, do let me me know.
OK, here's some code:
// Set some values for the purpose of this example
$this->path = '/Users/jon/Development/Personal/Visualised/master/test-assets/import-png.svg';
$xsdPath = '/Users/jon/Development/Personal/Visualised/master/test-assets/xsd/SVG.xsd';
$reader = new XMLReader();
$reader->open($this->path);
$valid = $reader->setSchema($xsdPath);
$reader->close();
OK, so the XSD files I've got in my xsd folder are:
SVG.xsd
xlink.xsd
xml.xsd
It seems that the parser imports the second and third XSD from the first - I want any dependencies to be stored on disk, not retrieved from the internet.
OK, here's the output:
XMLReader::setSchema(): Element '{http://www.w3.org/2001/XMLSchema}import': Skipping import of schema located at '/Users/jon/Development/Personal/Visualised/master/test-assets/xsd/xml.xsd' for the namespace 'http://www.w3.org/XML/1998/namespace', since this namespace was already imported with the schema located at 'http://www.w3.org/2001/xml.xsd'. in /Users/jon/Development/Personal/Visualised/master/lib/Visualised/Document.php on line 45
Warning: XMLReader::setSchema(): Element '{http://www.w3.org/2001/XMLSchema}attribute': The attribute 'type' is not allowed. in /Users/jon/Development/Personal/Visualised/master/lib/Visualised/Document.php on line 45
Warning: XMLReader::setSchema(): Element '{http://www.w3.org/2001/XMLSchema}attribute': The attribute 'type' is not allowed. in /Users/jon/Development/Personal/Visualised/master/lib/Visualised/Document.php on line 45
Warning: XMLReader::setSchema(): Element '{http://www.w3.org/2001/XMLSchema}attribute': The attribute 'type' is not allowed. in /Users/jon/Development/Personal/Visualised/master/lib/Visualised/Document.php on line 45
Warning: XMLReader::setSchema(): Unable to set schema. This must be set prior to reading or schema contains errors. in /Users/jon/Development/Personal/Visualised/master/lib/Visualised/Document.php on line 45
It seems like maybe I have imported the wrong version of a schema somewhere - I found all the XSD docs just through a web search. Any ideas?
Edit: the last error suggests the schema should be set before reading the document. OK, so I've changed the code to this:
$reader = new XMLReader();
$valid = $reader->setSchema($xsdPath);
$reader->open($this->path);
$reader->close();
-- some of the initial warnings go, but I still get the Unable to set schema one.
The XSD file for SVG you link to is from an old working draft version of SVG 1.1. There's currently no officially supported XML schema for SVG 1.1. Please see this answer for more details.
I'm trying to write some IPTC data to an image within an upload form in Codeigniter.
I can get it to read out the data great, but I need to be able to write it too.
Basically when I try and write the data, I get this error:
Severity: Warning
Message: iptcembed() [function.iptcembed]: Unable to open
http://www.mydomain.com/photos/testimage1.jpg
Filename: controllers/upload.php
Line Number: 139
Trouble is, the URL is correct, I don't understand why it can't open the file. The file is uploaded before the iptcembed() is run to ensure that it can find the image.
Line 139 is:
$path = base_url()."photos/".$filename;
$filename is the filename of the file that is uploaded earlier in the function.
I'm using the first example from the PHP Manual to write the IPTC data.
Ideas?
Probably the solution has been found, but just to share.
My problem was the full url, probably in this case
"$path = base_url()."photos/".$filename;" the base_url is causing that troubles.