473,408 Members | 2,832 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,408 software developers and data experts.

"Non-standard" xml file parsing...

Hi all,

I used simplexml_load_file function to parse all my xml feeds,
and found it to be the easiest option available. But, i recently
signed up for a feed which sends the xml file without the first
mandatory line, i.e, <?xml version="1.0" encoding="ISO-8859-1" ?>....
I learned that simplexml_ does not parse without the above
line, is this true, if yes, is there a way to add the above line once
retrieving the contents and passing it to simplexml_ function.
PLEASE HELP, I don't want to parse using good old dom or other
techniques.....

Thanks...

-Harsha
Jul 26 '08 #1
3 1410
Harsha schreef:
Hi all,

I used simplexml_load_file function to parse all my xml feeds,
and found it to be the easiest option available. But, i recently
signed up for a feed which sends the xml file without the first
mandatory line, i.e, <?xml version="1.0" encoding="ISO-8859-1" ?>....
I learned that simplexml_ does not parse without the above
line, is this true, if yes, is there a way to add the above line once
retrieving the contents and passing it to simplexml_ function.
PLEASE HELP, I don't want to parse using good old dom or other
techniques.....

Thanks...

-Harsha
sure, the most simple way is to store that 1 line in a file i.e. named
head.xml

and than do this on your system:
$ cat head.xml input.xml xmlwithhead.xml

--
Luuk
Jul 26 '08 #2
On Jul 26, 1:28*pm, Luuk <L...@invalid.lanwrote:
Harsha schreef:
Hi all,
* * * * I used simplexml_load_file function to parse all my xmlfeeds,
and found it to be the easiest option available. But, i recently
signed up for a feed which sends the xml file without the first
mandatory line, i.e, <?xml version="1.0" encoding="ISO-8859-1" ?>.....
* * * *I learned that simplexml_ does not parse without the above
line, is this true, if yes, is there a way to add the above line once
retrieving the contents and passing it to simplexml_ function.
* * * *PLEASE HELP, I don't want to parse using good old dom orother
techniques.....
Thanks...
-Harsha

sure, the most simple way is to store that 1 line in a file i.e. named
head.xml

and than do this on your system:
$ cat head.xml input.xml xmlwithhead.xml

--
Luuk
Thanks, I resolved the problem....
Jul 26 '08 #3
On Jul 26, 6:33 am, Harsha <harsha1...@gmail.comwrote:
Hi all,

I used simplexml_load_file function to parse all my xml feeds,
and found it to be the easiest option available. But, i recently
signed up for a feed which sends the xml file without the first
mandatory line, i.e, <?xml version="1.0" encoding="ISO-8859-1" ?>....
I learned that simplexml_ does not parse without the above
line, is this true, if yes, is there a way to add the above line once
retrieving the contents and passing it to simplexml_ function.
PLEASE HELP, I don't want to parse using good old dom or other
techniques.....

Thanks...

-Harsha
It might be an idea to file a complaint with the provider of the
feed. If it's missing the header then it's not a valid XML feed and
XML parsers are under no obligation to attempt to parse malformed
XML.
Jul 28 '08 #4

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

Similar topics

1
by: JKop | last post by:
Would you classify the following code as "Undefined Behaviour" or as "Non- portable"? signed main() { signed char chedder = 130; } Relevant information:
4
by: L Mehl | last post by:
Hello -- I am using Enterprise Architect, a UML modeling tool, which is built on a pre-Access 2000 mdb. The database describing the model has the extension ".eap". I want to build some...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
1
by: alex23 | last post by:
Hey everyone, I'm trying to install setuptools on a work PC behind an NTLM firewall. I've tried to use APS as recommended but am still unable to have anything other than IE talk through...
5
by: Aneesh Pulukkul[MCSD.Net] | last post by:
How to convert a "Non Serializable" object to byte array. The object is a dynamically created Excel workbook. As per my understanding an object can be written and read from a stream Only if it's...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
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...
0
tracyyun
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...
0
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,...

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.