Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way to read an XML file 2

Status
Not open for further replies.

natwod

Programmer
Nov 21, 2002
41
US
I was trying to use the domxml extension for PHP to read in an XML file, then run through the nodes (tags, attributes, text, everything) and then I'm going to map that data to a MySQL database.

But I just discovered the built in xmlparser functions, and I was wondering if they would be a better/more stable/more permanent solution.

Neither domxml or xmlparser very good documentation (samples and such). Would one be better than the other for what I want to do?

Also, I will be using characters from most foreign languages. Would this change what I should use? I tried using xmlparser with fopen, using a sample script from the documentation, and it just displayed a question mark for all the chinese characters.

Thanks in advance for your time and expertise.

Natwod
 
Also, if anybody can point me to a tutorial on either domxml or xmlparser, that would be fantastic.

Thx
Natwod
 
I think the xml stuff is still classed as experimental in 4.x. I got a wrox book called PHP XML which was ok ish, I belive php5 has better XML facilties.
 
Not sure about your XML question, however, your problem with asian characters I might be able to help. Thats a character encoding issue. For 'special' exended character sets, you need to use Unicode encoding.

It's just a simple conversion setting some text editors offer (you have to convert the file BEFORE you paste the characters in, usually). I doubt notepad offers it. It's been awhile sinse I did any localisation, but... Last time I used Ultraedit I think. If you're a Macromedia person, DreamweaverMX2004 supports Unicode. Other than that, it's a recently noticed issue thats become a feature many current editors are starting to offer. Maybe look on sourceforge.net and see if someone has an open source editor that handles unicode.
 
iirc devshed had a decent tutorial on using xmlparse.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
K, thanks for all your great replies. I got a couple more questions now.

I tried turning my PHP document into Unicode (notepad supports this, just go to 'save as'), but when I ran the PHP file on my server, it just showed the code and didn't run at all. Did I want to change the XML document to Unicode instead? When I open the XML file in internet explorer, the foreign characters display fine.

Also, would PHP 5 Candidate 3 be a better choice than trying to get it to work w/ PHP 4? Is it easy to install, and stable enough to use?

Thanks!
Natwod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top