Hi,
I´m having some problems with simplexml_load_file() and cant find any
sollution anywhere.
Say, we have the following file:
---file.xml---
<UNITS>Metric</UNITS>
<UNITS>another</UNITS>
--------------
The following code:
-------------------
$file = "file.xml";
$xml = simplexml_load_file($file) or die ("cant read file!");
echo $xml->UNITS[0];
-------------------
Gives me back "Metric", which it should do.
Now assume someone else uploads the following file:
---file.xml---
<units>Metric</units>
<units>another</units>
--------------
The output is empty, because of the case-sensitivity.
I cant influence how the user upload the files (upper or lower case in
the tags), how can i solve this problem?
I found xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true )
but it wont affect simplexml_load_file.
Any suggestions?
Thanks,
Rainer 3 3684
Rainer Mohr (ra*********@wiwi.uni-regensburg.de) wrote:
: Hi,
: I´m having some problems with simplexml_load_file() and cant find any
: sollution anywhere.
: Say, we have the following file:
: ---file.xml---
: <UNITS>Metric</UNITS>
: <UNITS>another</UNITS>
: --------------
: The following code:
: -------------------
: $file = "file.xml";
: $xml = simplexml_load_file($file) or die ("cant read file!");
: echo $xml->UNITS[0];
: -------------------
: Gives me back "Metric", which it should do.
: Now assume someone else uploads the following file:
: ---file.xml---
: <units>Metric</units>
: <units>another</units>
: --------------
: The output is empty, because of the case-sensitivity.
: I cant influence how the user upload the files (upper or lower case in
: the tags), how can i solve this problem?
Why not? The user needs to use the correct format for the data, and XML
is quite definitively case sensitive.
Define a DTD or schema and require the user to send data that is valid
according to that.
: I found xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true )
: but it wont affect simplexml_load_file.
The XML_OPTION_CASE_FOLDING is a kludge to help with handling things like
html, it should always be turned off for any regular xml parsing.
--
This space not for rent.
Hi Malcolm
Malcolm Dew-Jones wrote: Why not? The user needs to use the correct format for the data, and XML is quite definitively case sensitive.
I Know, but I cant influence what the users upload. Their xml data is
created by different softwares and they dont even know what is in the
files. They cant influence what the softwares do anyway.
: I found xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true ) : but it wont affect simplexml_load_file.
The XML_OPTION_CASE_FOLDING is a kludge to help with handling things like html, it should always be turned off for any regular xml parsing.
The data in the XML files is tranferred to a mysql database and then
deleted. So I dont need the file afterwards. It would just be nice to be
able to get the data into the database without asking the user to clean
it up (for they wont).
Therefore, can i influece simplexml_load_file with the
XML_OPTION_CASE_FOLDING in any way? If yes, then how?
Thanks again,
Rainer
Rainer Mohr said the following on 10/06/2005 19:30: Hi Malcolm
Malcolm Dew-Jones wrote:
Why not? The user needs to use the correct format for the data, and XML is quite definitively case sensitive.
I Know, but I cant influence what the users upload. Their xml data is created by different softwares and they dont even know what is in the files. They cant influence what the softwares do anyway.
Yes, but then that's their problem, not yours. If they upload invalid
XML, then that's their fault.
XML is supposed to be case-sensitive. If their software thinks
otherwise, then their software is wrong.
If you still want to work around this, then either use the event-driven
XML functions which allow you to ignore case, or build your own XML
parser (which isn't actually that hard).
--
Oli This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Barbara White |
last post by:
Are meta tags case sensitive or does case sensitivity vary depending on
the search engine a user is using?
I've read that some search engines care about case wrt meta tags (for
keywords in particular) and I've read that other search engines aren't
case sensitive. Is this true? Is there a listing of which search engines
pay attention to case...
|
by: Barbara White |
last post by:
Are meta tags case sensitive or does case sensitivity vary depending on
the search engine a user is using?
I'm wondering whether there's a standard regarding case (and other
rules) in meta tags (meta data in general). I couldn't find anything
definitive, but I could just be mis-searching. (Maybe I searched using
the wrong case. :-)
...
|
by: Eric Lindsay |
last post by:
Should HTML 4.01 Strict markup be done in upper case or in lower case?
I understand that HTML allows either upper or lower case. I also notice
that XHTML apparently requires lower case. However I saw some mention
that the HTML DOM uses upper case for markup elements.
So, should I worry about what this means?
I am inclined to go with...
|
by: Bill H |
last post by:
I wouldn't consider myself a newbie to PHP since I have never written
one line of code in it (am a perl guy myself), but part of a team I am
working with is writing some php interfaces into a database and I
noticed that they are relaying on HTML form value names to always be
lowercase in their code (ie $_POST (fyi that may be typed
wrong))...
|
by: Harsha |
last post by:
Hi All,
I am using simplexml_load_file function to parse xml files on
my localhost. But the server hosting my domain has php 4.x.x. so i
want to use php 4.x.x instead,
Is there a way to install simplexml_load_file function on php
4, if yes PLEASE let me know, else PLEASE suggest a function to parse
xml files easily......
Thank u....
| |
by: alexus |
last post by:
i have test.xml file that i pull from someone, and when i try to load
it up into php
I get this
mbp:cj alexus$ php api.php
SimpleXMLElement Object
(
)
mbp:cj alexus$
|
by: flydev |
last post by:
Hi,
I am having issues using simplexml. I have generated an XML file using PHP (link), and I am trying to load it into a simplexml object using:
$xml = simplexml_load_file("news_headlines_xml.php");
This is generating a parser error:
It looks as if it's trying to parse the actual PHP script, and not the generated XML. I have set the...
|
by: SnakesRule |
last post by:
I'm trying to pull data from remote xml files to load the database of a library. My sources are www.amazon.com and www.ISBNdb.com. But when I try to search and read the xml files, I get this error:
When I open the resulting URLs in a browser, I can see the xml data just fine, and I have tried this on to different computers and servers,...
|
by: newzdog |
last post by:
Hi,
I have a problem parsing an rss feed using simplexml_load_file - this is strange as i have used the same code to parse literally 1000s of different rss feeds in the past, and even stranger in that if i put the feed source on our server as a .xml file then my code parses it successfully.
The relevant code snippet:
$xml =...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |