View previous topic :: View next topic |
Author |
Message |
hastx -
Joined: 13 Nov 2006 Posts: 6
|
Posted: Mon Nov 13, 2006 10:36 pm Post subject: XML Parsing |
|
|
I am having an issue with parsing an XML file on a Windows pc with Abyss.
The output being sent to the browser is random and oriental looking charecters.
This code does work fine on a linux system with Apache, but I have not been able to get this code working with the windows system.
Code: |
<?
error_reporting ('E_All');
$xmlFile = 'sub_contacts.xml';
$parser = xml_parser_create('');
$fp = fopen($xmlFile, 'r');
$data = fread($fp, filesize($xmlFile));
xml_parse_into_struct($parser,$data,$values);
xml_parser_free($parser);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Sub Contacts</title>
</head>
<body>
<?php
$i = 0; // set the array counter variable
while ($i < count($values)) {
echo "<div class=\"org\">\r\n";
foreach ($values[$i][attributes] as $attribute => $value){
if ($attribute == "ORGANIZATION_X0020_NAME"){
echo "<div class=\"company\">".$value."</div>\r\n";
}
}
echo "</div>\r\n<br>\r\n";
$i++;
}
?>
|
The server is running Abyss X1 free version. I have another canned script that parses an xml file ok on the same server, so i wonder if there is an option i am not setting in the code?!? |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Nov 13, 2006 11:01 pm Post subject: Re: XML Parsing |
|
|
The code looks fine to me.
If you have oriental characters in the xml file, then you might need to set the character encoding
Otherwise, if you give an example of the contents of the xml file you are using, then we might be able to help you a bit more. _________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
hastx -
Joined: 13 Nov 2006 Posts: 6
|
Posted: Mon Nov 13, 2006 11:45 pm Post subject: |
|
|
OK, I made a nOOb mistake. The chinese charecters were the result of a previous mistake....I just cleared the browser cache and it is working now....now I won't really know what it was that was causing the weird output.
always clear the cache... :oops: |
|
Back to top |
|
 |
|