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 3 3714
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.
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 and which don't?
I have also read that some search engines throw away pages that repeat...
|
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
|
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.
|
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...
|
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 MIME type on the PHP file to text/xml. Here is the script that generates the XML:
|
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):
|
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...
|
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...
|
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,...
| |
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...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |