[PHP-DB] xml parsing

2005-06-16 Thread Wendell Frohwein
Hello everyone. I got this script that sends XML data to United Parcel
Service (UPS) to receive rates.
XML data is sent to the server, and a response is sent back also in XML.

The problem is the parser, the data gets fed into it by url only, and I
would like to feed data to it via a variable that is filled by the curl
process of sending / receiving the XML.

Here is the parser and how I retrieve the data from it:



function startElement($parser, $name, $attrs=''){
  global $ary_path;
  array_push($ary_path, $name);
}

function endElement($parser, $name, $attrs=''){
  global $ary_path;
  array_pop($ary_path);
}

function characterData($parser, $data){
  global $ary_parsed_file, $ary_path, $int_starting_level;
  $str_trimmed_data = trim($data);
  if (!empty($str_trimmed_data)) {
$str_array_define = '$ary_parsed_file';
  for ($i = $int_starting_level; $i  count($ary_path); $i++) {
$str_array_define .= '[\'' . $ary_path[$i] . '\']';
  }
  $str_array_define .=  = ' . $str_trimmed_data . ';;
  eval($str_array_define);
   
  // DEBUG
  //echo \n . $str_array_define;
   
  } // if
}


$ary_path = array();
$ary_parsed_file = array();
$int_starting_level = 1;

$xml_file =
'http://www.domain.com/rates.php?zip='.$_SESSION[shipto_zip].'session
='.session_id().shiptype=.$_SESSION[shiptype];

$type = 'UTF-8';

$xml_parser = xml_parser_create($type);
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, 'UTF-8');
xml_set_element_handler($xml_parser, 'startElement','endElement');
xml_set_character_data_handler($xml_parser, 'characterData');

if (!($fp = fopen($xml_file, 'r'))) {
   die(Could not open $xml_file for parsing!\n);
}



while ($data = fread($fp, 1024000)) {
   if (!($data = utf8_encode($data))) {
   echo 'ERROR'.\n;
   }
   if (!xml_parse($xml_parser, $data, feof($fp))) {
   die(sprintf( XML error: %s at line %d\n\n,
   xml_error_string(xml_get_error_code($xml_parser)),
   xml_get_current_line_number($xml_parser)));
   }
}
xml_parser_free($xml_parser);

//print_r($ary_parsed_file);


#/ This loads up retrieves values into sessions for use in the
shopping cart.
$_SESSION[shipping_price]=$ary_parsed_file['RATEDSHIPMENT']['TOTALCHAR
GES']['MONETARYVALUE'];
$_SESSION[shipping_weight]=$ary_parsed_file['RATEDSHIPMENT']['BILLINGW
EIGHT']['WEIGHT'];




The file this script is connecting to (rates.php) is the actual script
and curl process that sends / receives the XML data to and from ups's
servers. The above code is just the parser.



Thank you in advance for any help.

-Wendell Frohwein

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] xml to mysql tables using php

2005-06-12 Thread babu
Hi all,
 
I have seen in zend.com about parsing an xml document using php.
i have also seen an interesting article which uses perl or java to move data 
from xml to database and vice versa.
Does php has such functions to do so.
 
Thanks


-
How much free photo storage do you get? Store your holiday snaps for FREE with 
Yahoo! Photos. Get Yahoo! Photos

[PHP-DB] xml, PHP, MYSQL

2005-04-05 Thread J. Connolly
I think i was dropped from the mailing list. So this message is twofold.
My second part is...
Is there a performance difference in returning a MySQL query in XML 
format? Is it a matter of preference whether the conversion takes place 
in php or mysql? I didn't even know mysql was capable of this until two 
days ago and I am having a difficult time putting the pieces together. I 
have already looked at the SimpleXML in php.net and the parsing 
functions as well.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] XML to MySQL

2003-07-02 Thread Nabil
Dear All ;

I have an XML files like the following and i want to make an PHP code to
insert it into my MySQL
how can i read the nodes ot tages???  by the way i can export like this file
from PhpMyAdmin but i cann't dump it back...
Thanks in advance
Nabil

?xml version=1.0 encoding=windows-1252 ?
- scs-dist
- !--
 table dist   --
- dist
  id1/id
  fnameMark/fname
  lnameSmith/lname
  companycompany1/company
  phone123456/phone
  governcity1/govern
  addressfirst street/address
  area12/area
/dist



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] XML

2002-06-27 Thread Peter Lovatt

Hi

I am looking at a project using XML to import and export data into MySql
directly or using php. The datasets are quite large (40-50 million records)

I haven't used XML before.

Does it take long to work out how to use php/XML? Are there any problems
working with large datasets?

Thanks

Peter



---
Excellence in internet and open source software
---
Sunmaia
www.sunmaia.net
[EMAIL PROTECTED]
tel. 0121-242-1473
---

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 27 June 2002 17:43
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: PHP and msql Error


 The error is in your MySql statement.  Sounds like you are calling the
 wrong data field / column.  Check you spelling and syntax to make sure
 all of that is in order.  If you can't find it, copy it and post it.
 We'll help you out

 gl -- Seth

 Comp Boy wrote:

   I am getting the following error:
 
   Warning: Supplied argument is not a valid mSQL result resource in
   /usr/local/apache/htdocs/inc/listings.inc on line 24
 
   listings.inc: 24
   $numRows = msql_numrows( $result );
 
   The manual on php.net says that it takes no variables
 msql_numrows(void)
   however it says it is another version of msql_num_rows(int msql);
 
   The code I am trying to run, runs perfectly fine on another one of our
  systems.  I was just setting up a development server and now I
 am getting
  this problem.  The specs are the same except for the version of Apache
  production is 1.3.9 and development is 1.3.26
 
   PHP vesrion 4.1.2
 
   ./msqladmin version
   Version Details :-
   msqladmin version   2.0.11
   mSQL server version 2.0.11
   mSQL protocol version   23
   mSQL connection Localhost via UNIX socket
   Target platform Linux-2.2.14-5.0-i686
 
  PHP was configured:
  ./configure --with-apxs=/usr/local/apache/bin/apxs --with-msql
 
  msql was a default install.
 
  Does anyone know what I did wrong?  Do I need to recompile with some
  different options?
 
  TIA
  Jason
 
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] XML

2002-06-27 Thread B i g D o g

MySQL has xml support...have you looked at the docs at mysql.com for
anything that might help you input the data directly...


B i g D o g


- Original Message -
From: Peter Lovatt [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, June 27, 2002 3:03 PM
Subject: [PHP-DB] XML


 Hi

 I am looking at a project using XML to import and export data into MySql
 directly or using php. The datasets are quite large (40-50 million
records)

 I haven't used XML before.

 Does it take long to work out how to use php/XML? Are there any problems
 working with large datasets?

 Thanks

 Peter



 ---
 Excellence in internet and open source software
 ---
 Sunmaia
 www.sunmaia.net
 [EMAIL PROTECTED]
 tel. 0121-242-1473
 ---

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: 27 June 2002 17:43
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: [PHP-DB] Re: PHP and msql Error
 
 
  The error is in your MySql statement.  Sounds like you are calling the
  wrong data field / column.  Check you spelling and syntax to make sure
  all of that is in order.  If you can't find it, copy it and post it.
  We'll help you out
 
  gl -- Seth
 
  Comp Boy wrote:
 
I am getting the following error:
  
Warning: Supplied argument is not a valid mSQL result resource in
/usr/local/apache/htdocs/inc/listings.inc on line 24
  
listings.inc: 24
$numRows = msql_numrows( $result );
  
The manual on php.net says that it takes no variables
  msql_numrows(void)
however it says it is another version of msql_num_rows(int msql);
  
The code I am trying to run, runs perfectly fine on another one of
our
   systems.  I was just setting up a development server and now I
  am getting
   this problem.  The specs are the same except for the version of Apache
   production is 1.3.9 and development is 1.3.26
  
PHP vesrion 4.1.2
  
./msqladmin version
Version Details :-
msqladmin version   2.0.11
mSQL server version 2.0.11
mSQL protocol version   23
mSQL connection Localhost via UNIX socket
Target platform Linux-2.2.14-5.0-i686
  
   PHP was configured:
   ./configure --with-apxs=/usr/local/apache/bin/apxs --with-msql
  
   msql was a default install.
  
   Does anyone know what I did wrong?  Do I need to recompile with some
   different options?
  
   TIA
   Jason
  
  
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] xml doccument validation ?????

2002-05-20 Thread toby z

guyz 
its terrable 
i have a well formed xml doccument 
but i cant get it validated ...
i keep getting this error
this file is not valid. all fields referred to from
the key identity constraint 'user_info_memb_id' 
must exist

now 
i had made 6 tables in access 
but i made a schema in xml from the scratch ... no
import from access u know ...
and i defined all my table names as schema elements
 with sub elements and attributes 

the xml doccument is :

?xml version=1.0 encoding=UTF-8?
user-info
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:noNamespaceSchemaLocation=F:\New Folder (2)\final
project\d bs\proj_db.xsd
role
memb/
modrtr/
/role
member
memb-id/
email/
name firstName= lastName=/
login password= login=/
news-letter-subscription/
lang-id/
country/
/member
/user-info


where am i messing it up 

oh  i ve generated this thru xml spy ..if that helps
.
:( .

will somebody plz help 
i'd really appriciate any help ... any word on this
.

stuck az usual  :( 

toby ..


__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] xml doc validation .... details ...... ! ! ! !

2002-05-20 Thread toby z

well  its something like 

i need to take user input and store it somewhere 
and then retrieve it back thru DOM 

and i guess i need to store that input in an xml
doccument like the one i sent earlier 
or do i 

now the thing that im most concerned bout is .
this doccument or anyother that i try tomake using the
scheema doesent get validated 
i keep getting an error fo one of the fields for each
.

i've tried changing the field types  but ...
even that doesnt change anything ..


secondly  i made a single scheema . and i
included all the elements in it .
user-info, content-info, categry,..
with all their subelements .
i think im right  or am i 

third .i have a few elements in the scheema that
are repeated .

do u think that cud be the problem  ?

so thats it ...
if u want me to tell u more  plz do let me know


thnx a million 

toby 




__
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] xml doc validation .... details ...... ! ! ! !

2002-05-20 Thread szii

Your questions are far too vague and XML/XML:Schema/XSLT etc
are far too complicated to explain without definitive focus'd questions.

XML allows you to do whatever YOU want in whatever format
YOU want. 

Best help I can give is this...

http://www.w3.org/

'Luck

-Szii

- Original Message - 
From: toby z [EMAIL PROTECTED]
To: php db [EMAIL PROTECTED]
Sent: Monday, May 20, 2002 6:52 PM
Subject: [PHP-DB] xml doc validation  details .. ! ! ! ! 


 well  its something like 
 
 i need to take user input and store it somewhere 
 and then retrieve it back thru DOM 
 
 and i guess i need to store that input in an xml
 doccument like the one i sent earlier 
 or do i 
 
 now the thing that im most concerned bout is .
 this doccument or anyother that i try tomake using the
 scheema doesent get validated 
 i keep getting an error fo one of the fields for each
 .
 
 i've tried changing the field types  but ...
 even that doesnt change anything ..
 
 
 secondly  i made a single scheema . and i
 included all the elements in it .
 user-info, content-info, categry,..
 with all their subelements .
 i think im right  or am i 
 
 third .i have a few elements in the scheema that
 are repeated .
 
 do u think that cud be the problem  ?
 
 so thats it ...
 if u want me to tell u more  plz do let me know
 
 
 thnx a million 
 
 toby 
 
 
 
 
 __
 Do You Yahoo!?
 LAUNCH - Your Yahoo! Music Experience
 http://launch.yahoo.com
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] XML coming out from MySQL

2001-11-10 Thread Tomas Garcia Ferrari

 I've never parsed XML with PHP, but it might help if you can show the
 document that's breaking the parser, and also let us know if other
 documents are working fine...
 
 -Lorenzo

Hi,

The document is like this:

?xml version=1.0 encoding=iso-8859-1?
articulo
volantaSome text/volanta
tituloSome text/titulo
bajadaSome text/bajada
parrafoSome text/parrafo
urlhttp://whatever.com//url
copyWhomever 2001/copy
/articulo

Up to now, I solve the problem modifying the lines saying
 while ($data = $file) {
 if (!xml_parse($xml_parser, $data, 0)) {
 die(sprintf(XML error: %s at line %d,
 xml_error_string(xml_get_error_code($xml_parser)),
 xml_get_current_line_number($xml_parser)));
 }
 }

into
 xml_parse($xml_parser, $data, 0);

I'd noticed that I don't need to read the document line by line.

Regards and thanks,
Tomás


+-- --+
   Tomás García Ferrari
   Bigital
   http://bigital.com/
+-- --+



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] XML coming out from MySQL

2001-11-09 Thread Tomas Garcia Ferrari

Hello,

I'm trying to parse an XML file stored on MySQL. I'm using this code:

 ?php
 global $CFG, $ME;
 
 $qid = db_query(
 SELECT texto
 FROM articulos
 WHERE id = $id
 );
 
 $r = db_fetch_object($qid);
 $file = $r-texto;
 
 
 $map_array = array(
 ARTICULO = ,
 VOLANTA = h2,
 TITULO = h1,
 SUBTITULO = h3,
 BAJADA  = h2,
 PARRAFO  = p,
 AUTOR  = h3,
 URL  = h3,
 COPY  = h3
 );
 
 function startElement($parser, $name, $attrs) {
 global $map_array;
 if ($htmltag = $map_array[$name]) {
 print $htmltag;
 }
 }
 
 function endElement($parser, $name) {
 global $map_array;
 if ($htmltag = $map_array[$name]) {
 print /$htmltag;
 }
 }
 
 function characterData($parser, $data) {
 print $data;
 }
 
 $xml_parser = xml_parser_create();
 // use case-folding so we are sure to find the tag in $map_array
 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
 xml_set_element_handler($xml_parser, startElement, endElement);
 xml_set_character_data_handler($xml_parser, characterData);
 
 while ($data = $file) {
 if (!xml_parse($xml_parser, $data, 0)) {
 die(sprintf(XML error: %s at line %d,
 xml_error_string(xml_get_error_code($xml_parser)),
 xml_get_current_line_number($xml_parser)));
 }
 }
 xml_parser_free($xml_parser);
 ?

and having this at the end of the outuput:

 XML error: junk after document element at line 25

What does it mean? How can I solve it / trace it?

Regards,
Tomás

+-- --+
   Tomás García Ferrari
   Bigital
   http://bigital.com/
+-- --+



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] XML coming out from MySQL

2001-11-09 Thread Gonzalez, Lorenzo

I've never parsed XML with PHP, but it might help if you can show the
document that's breaking the parser, and also let us know if other
documents are working fine...
 
-Lorenzo

-Original Message- 
From: Tomas Garcia Ferrari 
Sent: Fri 11/9/2001 5:14 PM 
To: [EMAIL PROTECTED] 
Cc: 
Subject: [PHP-DB] XML coming out from MySQL



Hello,

I'm trying to parse an XML file stored on MySQL. I'm using this
code:

 ?php
 global $CFG, $ME;

 $qid = db_query(
 SELECT texto
 FROM articulos
 WHERE id = $id
 );

 $r = db_fetch_object($qid);
 $file = $r-texto;


 $map_array = array(
 ARTICULO = ,
 VOLANTA = h2,
 TITULO = h1,
 SUBTITULO = h3,
 BAJADA  = h2,
 PARRAFO  = p,
 AUTOR  = h3,
 URL  = h3,
 COPY  = h3
 );

 function startElement($parser, $name, $attrs) {
 global $map_array;
 if ($htmltag = $map_array[$name]) {
 print $htmltag;
 }
 }

 function endElement($parser, $name) {
 global $map_array;
 if ($htmltag = $map_array[$name]) {
 print /$htmltag;
 }
 }

 function characterData($parser, $data) {
 print $data;
 }

 $xml_parser = xml_parser_create();
 // use case-folding so we are sure to find the tag in
$map_array
 xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING,
true);
 xml_set_element_handler($xml_parser, startElement,
endElement);
 xml_set_character_data_handler($xml_parser, characterData);

 while ($data = $file) {
 if (!xml_parse($xml_parser, $data, 0)) {
 die(sprintf(XML error: %s at line %d,
 xml_error_string(xml_get_error_code($xml_parser)),
 xml_get_current_line_number($xml_parser)));
 }
 }
 xml_parser_free($xml_parser);
 ?

and having this at the end of the outuput:

 XML error: junk after document element at line 25

What does it mean? How can I solve it / trace it?

Regards,
Tomás

+-- --+
   Tomás García Ferrari
   Bigital
   http://bigital.com/
+-- --+



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail:
[EMAIL PROTECTED]