473,796 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Case sesitivity in XML Tags and simplexml_load_ file()

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>anothe r</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>anothe r</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
Jul 17 '05 #1
3 3711
Rainer Mohr (ra*********@wi wi.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>anothe r</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>anothe r</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.
Jul 17 '05 #2
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
Jul 17 '05 #3
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
Jul 17 '05 #4

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

Similar topics

2
8138
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 and which don't? I have also read that some search engines throw away pages that repeat...
3
3049
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. :-) Thanks for any information. Barbara
19
26451
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 lower case, for two reasons. Easier to change if I subsequently want to use XHTML.
32
8214
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)) and from my experience it is always better, when reading in the post information to convert the the...
2
6497
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....
7
6067
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$
7
10909
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 MIME type on the PHP file to text/xml. Here is the script that generates the XML:
1
7208
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, with the same result. Here is my code (minus the access keys for the databases):
4
11360
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 = simplexml_load_file("http://www.quidco.com/blog/?feed=rss2",'SimpleXMLElement', LIBXML_NOCDATA); The errors i get...
0
9685
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, 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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10467
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10244
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10201
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9061
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.