PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old December 1st, 2008, 02:58 PM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Fetching XML data from URL

Hello all,

I am using this code:

PHP Code:
 $source_artikli file_get_contents('https://www.it4profit.com/login/authorize2.jsp?USERNAME=xx&PASSWORD=xyxx&REFPAGE=%2Fecatalog%2Futils%2FPriceGenerator.jsp%3  FLANG%3Den%26COMP_CODE%3D709%26SEARCH_CODE%3D%26MA  NUFACTURER_NAME%3D%26TYPE_NAME%3D');


if (!
$y->fetch($source_artikli)) { 
 
  echo 
"<h2>There was a problem parsing your XML!</h2>"
  echo 
$y->log
  exit();
  



Now... i get this error:

Code:
There was a problem parsing your XML!
New xml() object instantiated.
fetch() called.
XML error: SYSTEM or PUBLIC, the URI is missing at line 3


What does that error mean? how can i fix it?

The same code works fine for other URL (from other distributor).

Thank you!

Reply With Quote
  #2  
Old December 1st, 2008, 04:28 PM
MatthewJ MatthewJ is offline
Contributing User
Click here for more information.
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 558 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 20 h 30 m 15 sec
Reputation Power: 3
This would only be a guess because the service is password protected and I can't view what the result of the file_get_contents call, but like the error says, this link is failing to return a URI for this call... since the others work, you should echo out the contents of $source_artikli for one that works, then this one, and see what the differences are.

Reply With Quote
  #3  
Old December 1st, 2008, 05:52 PM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
hm.... i tried... and i get this:

Code:
http://nemesis-hr.net/gameover/update-asbis.php


But i should be getting some XML .. for example like this...

Example: to get invoices for the period from May 10 till May 20 of year 2007:

Code:
https://www.it4profit.com/login/authorize2.jsp?USERNAME=User_ID&PASSWORD=User_Password&REFPAGE=%2Flite%2FInvoiceList.jsp%3F%26DATE_FROM=1  0/05/2007%26DATE_TILL=20/05/2007%26COMP_CODE=709 



Invoice XML description.
Code:
<Invoice>
  		<InvoiceNumber /> 
  	<InvoiceDate>20/03/2007</InvoiceDate> 
<CurrencyCode>USD</CurrencyCode> 
  		<OrderNumber /> 
  		<OrderRefNumber>154574</OrderRefNumber> 
<OrderRefID>70320105817218119</OrderRefID> 
<TotalAmount>2146.75</TotalAmount> 
<VAT>0.0000</VAT> 
<TotalAmountWithVAT>2146.7500</TotalAmountWithVAT> 
<ItemList>
<Item>
  <LineKey>70320105817647299</LineKey> 
  <ItemCode>CN-HDD35250</ItemCode>
  <SKU>CNHDD35250</SKU>
  <Qty>25</Qty> 
  <Price>85.87</Price> 
  <VAT>0.0000</VAT> 
  <PriceWithVAT>85.8700</PriceWithVAT> 
  	</Item>
</ItemList>
  </Invoice>



System Admin from IT4Profit told me to use that URL which I am Using! Please advise!

Thank you!

Reply With Quote
  #4  
Old December 2nd, 2008, 05:50 AM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Ok i solved my problem!! THANKS for TIP!

but now i have other prob )

i have XML file size = 5.6MB

and i read that file with:
Code:
if (!$y->fetch($source_artikli)) { ... 


but i get server error:
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 35 bytes)

How is that posible if the file is only 5mb? When i do echo $source_artikli i get normal results...

thank you!

Reply With Quote
  #5  
Old December 2nd, 2008, 05:59 AM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
4,194,3040 bytes is about 4mb, so you can only open approx 4mb file (4,718,592 is read as 4.5mb (from a file on my hdd)).

So something is limiting you to 4mbs files.
__________________
~~==~~ Whoever said nothing is impossible never tried pushing a revolving door ~~==~~

Reply With Quote
  #6  
Old December 2nd, 2008, 07:11 AM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Ok.. i manage to avoid that problem ^_^

now i have this problem (seems like i have only problems )

i fetch xml data with this:

PHP Code:
foreach ($y->data->CONTENT[0]->PRICES[0]->PRICE as $var) { 
  
  
#Get Partnumber
  
$part_num $var->WIC[0]->_text;
  echo 
"<br />".$part_num; } 


But why do i get results like this:
Code:
<br />2213700-RASC-29320LPE_SGLbravo<br />bravo<br />Ukupno artikala:2


When the XML file is:
Code:
<CONTENT>
<COMP_CODE>709</COMP_CODE>
<LANG>hr</LANG>
<COMP_CODE_BUYER>80530085911858417</COMP_CODE_BUYER>
<SEARCH_CODE></SEARCH_CODE>
<MANUFACTURER_NAME></MANUFACTURER_NAME>
<TYPE_NAME></TYPE_NAME>
<PRICES>
<PRICE>
<WIC>2213700-R</WIC>
<DESCRIPTION>ADAPTEC Battery Module 500 Backup Battery Lithium Ion</DESCRIPTION>
<VENDOR_NAME>ADAPTEC</VENDOR_NAME>
<GROUP_NAME>Power - Battery</GROUP_NAME>
<VPF_NAME>Battery Module 500</VPF_NAME>
<CURRENCY_CODE>HRK</CURRENCY_CODE>
<AVAIL>0</AVAIL>
<RETAIL_PRICE>722.10</RETAIL_PRICE>
<MY_PRICE>664.33</MY_PRICE>
<WARRANTYTERM>12</WARRANTYTERM>
<GROUP_ID>103</GROUP_ID>
<VENDOR_ID>3</VENDOR_ID>
<PICT_SMALL>http://www.it4profit.com/catalogimg/wic/1/2213700-R</PICT_SMALL>
<ITEM_LINK>http://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=51108132711259053&THEME=asbis&LANG=hr</ITEM_LINK>
</PRICE>
<PRICE>
<WIC>ASC-29320LPE_SGL</WIC>
<DESCRIPTION>Controller ADAPTEC SCSI 29320LPE Ultra320 SCSI PCI Express X1 1ch</DESCRIPTION>
<VENDOR_NAME>ADAPTEC</VENDOR_NAME>
<GROUP_NAME>Controller Card</GROUP_NAME>
<VPF_NAME>SCSI 29320LPE</VPF_NAME>
<CURRENCY_CODE>HRK</CURRENCY_CODE>
<AVAIL>0</AVAIL>
<RETAIL_PRICE>1160.00</RETAIL_PRICE>
<MY_PRICE>1038.20</MY_PRICE>
<WARRANTYTERM>36</WARRANTYTERM>
<GROUP_ID>110</GROUP_ID>
<VENDOR_ID>3</VENDOR_ID>
<PICT_SMALL>http://www.it4profit.com/catalogimg/wic/1/ASC-29320LPE_SGL</PICT_SMALL>
<ITEM_LINK>http://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=70313123403415873&THEME=asbis&LANG=hr</ITEM_LINK>
</PRICE>
</PRICES>
</CONTENT>


So i Should be getting resoults like:
<br />2213700-Rbravo
<br />ASC-29320LPE_SGLbravo
<br />Ukupno artikala:2

?? WHat am i doing wrong please?

thank you very much if you come to Croatia I buy you a drink

Reply With Quote
  #7  
Old December 2nd, 2008, 07:24 AM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
well I don't know a lot about XML, but it looks like it thinks that the two <WIC> tags are infact one string, so it sees it as 2213700-RASC-29320LPE_SGL instead of 2213700-R & ASC-29320LPE_SGL.

But thats the limit of my contribution.

I also don't know where its getting bravo from or Ukupno artikala:2 from, as I can't see that in the XML file you've shown

Last edited by Osiris : December 2nd, 2008 at 07:29 AM.

Reply With Quote
  #8  
Old December 2nd, 2008, 08:09 AM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Sorry,this is the full code i pasted short one ^^

PHP Code:
foreach ($y->data->CONTENT[0]->PRICES[0]->PRICE as $var) { 
  
  
#Get Partnumber
  
$part_num $var->WIC[0]->_text;
  
  echo 
"<br />".$part_num;
  echo 
'bravo';
  
$x++;
  
                                                           }
                                                           echo 
'<br />Ukupno artikala:'.$x


even if i put all data from XML to echo.. WIC, Group Name etc... i get all data in one string... but i use same script on other XML file.... i get normal output... but when i fix script to work on other XML file.. i get this bug,error or what ever it is...

thank you

Reply With Quote
  #9  
Old December 2nd, 2008, 08:17 AM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
What does it look like when you echo out the XML file? Can you post it up?

Reply With Quote
  #10  
Old December 2nd, 2008, 08:42 AM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Echo it with
PHP Code:
 $source_artikli file_get_contents('it4test.xml'); 


or you mean something else?

You have the whole XML file in post above...

ty

Reply With Quote
  #11  
Old December 2nd, 2008, 08:48 AM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
So when you echo out the XML file, as in echo $source_artikli;, it just shows

Code:
<CONTENT>
<COMP_CODE>709</COMP_CODE>
<LANG>hr</LANG>
<COMP_CODE_BUYER>80530085911858417</COMP_CODE_BUYER>
<SEARCH_CODE></SEARCH_CODE>
<MANUFACTURER_NAME></MANUFACTURER_NAME>
<TYPE_NAME></TYPE_NAME>
<PRICES>
<PRICE>
<WIC>2213700-R</WIC>
<DESCRIPTION>ADAPTEC Battery Module 500 Backup Battery Lithium Ion</DESCRIPTION>
<VENDOR_NAME>ADAPTEC</VENDOR_NAME>
<GROUP_NAME>Power - Battery</GROUP_NAME>
<VPF_NAME>Battery Module 500</VPF_NAME>
<CURRENCY_CODE>HRK</CURRENCY_CODE>
<AVAIL>0</AVAIL>
<RETAIL_PRICE>722.10</RETAIL_PRICE>
<MY_PRICE>664.33</MY_PRICE>
<WARRANTYTERM>12</WARRANTYTERM>
<GROUP_ID>103</GROUP_ID>
<VENDOR_ID>3</VENDOR_ID>
<PICT_SMALL>http://www.it4profit.com/catalogimg/wic/1/2213700-R</PICT_SMALL>
<ITEM_LINK>http://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=51108132711259053&THEME=asbis  &LANG=hr</ITEM_LINK>
</PRICE>
<PRICE>
<WIC>ASC-29320LPE_SGL</WIC>
<DESCRIPTION>Controller ADAPTEC SCSI 29320LPE Ultra320 SCSI PCI Express X1 1ch</DESCRIPTION>
<VENDOR_NAME>ADAPTEC</VENDOR_NAME>
<GROUP_NAME>Controller Card</GROUP_NAME>
<VPF_NAME>SCSI 29320LPE</VPF_NAME>
<CURRENCY_CODE>HRK</CURRENCY_CODE>
<AVAIL>0</AVAIL>
<RETAIL_PRICE>1160.00</RETAIL_PRICE>
<MY_PRICE>1038.20</MY_PRICE>
<WARRANTYTERM>36</WARRANTYTERM>
<GROUP_ID>110</GROUP_ID>
<VENDOR_ID>3</VENDOR_ID>
<PICT_SMALL>http://www.it4profit.com/catalogimg/wic/1/ASC-29320LPE_SGL</PICT_SMALL>
<ITEM_LINK>http://content.it4profit.com/itshop/itemcard_cs.jsp?ITEM=70313123403415873&THEME=asbis  &LANG=hr</ITEM_LINK>
</PRICE>
</PRICES>
</CONTENT>

Last edited by Osiris : December 2nd, 2008 at 08:55 AM.

Reply With Quote
  #12  
Old December 2nd, 2008, 11:19 AM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
what happens if you change

foreach ($y->data->CONTENT[0]->PRICES[0]->PRICE as $var)

to

foreach ($y->data->CONTENT[0]->PRICES[0]->PRICE[] as $var)

notice the [] at the end of PRICE. It might make no difference whatsoever :p

But from what I can see your code should be working. Oh also, when I put your xml file into my own one it throughs an error about expected semicolon ';' for the <ITEM_LINK> lines, If I remove them then it works fine.
So I don't know if an error with your XML file is causing this bug

Last edited by Osiris : December 2nd, 2008 at 11:21 AM.

Reply With Quote
  #13  
Old December 2nd, 2008, 12:09 PM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
i get

PHP Code:
 Fatal errorCannot use [] for reading in /home/xx/public_html/xy/update-as2bis.php on line 41 


^_^

got some other idea?...

i will check xml file for errors...

Reply With Quote
  #14  
Old December 2nd, 2008, 12:32 PM
hrvoje89rijeka hrvoje89rijeka is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 44 hrvoje89rijeka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 h 25 m 16 sec
Reputation Power: 2
Code:
But from what I can see your code should be working. Oh also, when I put your xml file into my own one it throughs an error about expected semicolon ';' for the <ITEM_LINK> lines, If I remove them then it works fine.
So I don't know if an error with your XML file is causing this bug


I deleted ITEM_LINK lines but error is still here damn it!!! where is the problem?!?!

Reply With Quote
  #15  
Old December 2nd, 2008, 01:36 PM
Osiris Osiris is offline
Contributing User
Codewalkers Novice (500 - 999 posts)
 
Join Date: May 2008
Location: Sussex
Posts: 566 Osiris User rank is Private First Class (20 - 50 Reputation Level)Osiris User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 2 Days 19 h 54 m 33 sec
Reputation Power: 2
Well trying to help lol, but having problem with your code :p

PHP Code:
 $source_artikli=file_get_contents('XML.xml');


if (!
$y->fetch($source_artikli)) {
  echo 
"<h2>There was a problem parsing your XML!</h2>";
  echo 
$y->log;
  exit();
}

$x="";
foreach (
$y->data->CONTENT[0]->PRICES[0]->PRICE as $var) {

  
#Get Partnumber
  
$part_num $var->WIC[0]->_text;

  echo 
"<br />".$part_num;
  echo 
'bravo';
  
$x++;

}
echo 
'<br />Ukupno artikala:'.$x


its saying that $source_artikli is not an object, and I don't know how to get around that :p

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Fetching XML data from URL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
Stay green...Green IT