473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

PHP5 DOMDocument: specifying encoding programmatically

Shorter: How do I tell DOMDocument->load() what encoding I want it to use?

Longer: I search for and process XML files from elsewhere, and need to
transform them with some XSLTs. No problem. Using PHP5 and the DOM
library, everything's a snap. Worked fine, up till now. Today, funky
characters were in the XML file -- "smart" quotes from Word, it looks
like. Anyways, DOMDocument->load complained about them, saying that
they weren't UTF-8, and to specify the encoding.

Lo and behold, the encoding is not specified in these XML files. If I
add in 'encoding="iso-8859-1"' to the header, it works fine. The rub is
I have no control over these XML files.

Reading the file into a string, modifying its header and writing it back
out to another location seems to be my only option, but I'd prefer to do
it without having to use temporary copies of the XML files at all. Is
there any way to simply tell the parser to parse them as if they were
iso-8859-1?

--Colin McGuigan
Jul 17 '05 #1
0 2324

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rutger Claes | last post by:
Code and problem are from PHP5: When I execute the following piece of code, the DomException is thrown with a message: Not Found Exception. I assume this means that the node I extracted from the...
3
by: Philipp Lenssen | last post by:
I want to try the new Yahoo API, but I get the PHP5 error message Unknown encoding "utf-8" in the marked line below... (After that, applying the Xpath will fail as symptom of the first bug.) ...
1
by: dk_sz | last post by:
Is it just me... Or is PHP5 XML very limited? Or am I missing something very obvious? Any way to use PHP4 Dom XML in PHP5? Does anyone know why support for it was dropped? I have following...
2
by: dk_sz | last post by:
Can anyone point me to a guide or something for conversion? I tryed http://alexandre.alapetite.net/doc-alex/domxml-php4-php5/index.en.html but it doesn't work (not all parts anyway) - and as I...
2
by: al3x4nder | last post by:
I`m need hanling XSLT errors in my script, before I`m use Sablotron, that has nice interface for it: ------------8<------------------ function ProduceXHTML($xml, $xsl){ $xh = xslt_create();...
2
by: J˙Giusł vs ::NRG::ius | last post by:
Hi all. I have this script ----------------------------------------------------------- <?php $doc = new DOMDocument(); $doc->load('books.xml'); echo $doc->saveXML(); ?>
0
by: R | last post by:
Hi All, I've run into very disturbing problem, I must use html tags inside one of my XML node so I wrote: $cdataHelp = $DomDocument->createCDATASection($value); when I dump it as XML
2
by: mananvyas | last post by:
Hi, I am working on PHP5 and all the xmldom related extensions are installed and on properly. I am trying to execute following code but some how not working. $doc = new DomDocument();...
2
by: eltower | last post by:
adactio.com/journal/1202 has a very interesting PHP script which gathers RSS data from various feeds and prints them in an HTML table. He calls this a lifestream. Anyways, unfortunately, my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.