473,473 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Change returned data content type?

90 New Member
Bit of a toughie here I think.

I use (access 2003) HTTP.send function to open up a php file that's stored on an internal website.
The file queries one of our suppliers regarding stock (with xml format) and returns the response.
The php selects the nodes I want to display to the users, and Access displays it as a message box.

What I'd like to do, is return the selected nodes in a way that Access could automatically pick up and insert into fields in the database.

I use the http.send function for another, which directly posts to the suppliers website and returns the full xml; which I can then use
Expand|Select|Wrap|Line Numbers
  1. Set price = HTTP.responseXML.SelectSingleNode("//query/price")
to get the selected node.

I tried echoing the nodes into an xml format and extracting those; but it kept saying 'variable not set'. I have a hunch that might be because the content type is text, not xml.

Does anyone know if it's possible to return the selected nodes as xml so I can pick them up in access?

Does anyone even understand what I'm going on about lol

Thanks for any help
Mandi
Oct 10 '08 #1
5 1348
pbmods
5,821 Recognized Expert Expert
Heya, Mandi.

Which programming language are you using? That doesn't look like PHP.
Oct 10 '08 #2
mandanarchi
90 New Member
Heya, Mandi.

Which programming language are you using? That doesn't look like PHP.
That part isn't, that part is VBA. I'll post both the VBA and PHP.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $td_sku = $_REQUEST['sku'];
  3. $td_manu = $_REQUEST['manu'];
  4.  
  5. //Following the XML data
  6. $xmldata="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r
  7. <OnlineCheck>\r
  8. <Header>\r
  9. <BuyerAccountId>xxxxx</BuyerAccountId>\r
  10. <AuthCode>xxxxx-xxxxx-xxxxx</AuthCode>\r
  11. <Type>Full</Type>\r
  12. </Header>\r
  13. <Item line=\"1\">\r
  14. <ManufacturerItemIdentifier>$td_manu</ManufacturerItemIdentifier>t\r
  15. <ResellerItemIdentifier/>\r
  16. <DistributorItemIdentifier>$td_sku</DistributorItemIdentifier>\r
  17. <Quantity>1</Quantity>\r
  18. </Item>\r
  19. </OnlineCheck>";
  20.  
  21. $fp = fsockopen("supplierswebsite.com", 8080, $errno, $errstr, 15);
  22. //Generate the postdata on a valid way, $out4 needs to be calculated, so will be later.
  23. $out1 = "POST /Onlchk HTTP/1.0\r
  24. ";
  25. $out2 = "Content-Type: multipart/form-data; boundary=---------------------------2\r
  26. ";
  27. $out3 = "Host: supplierswebsite.com:8080\r
  28. ";
  29. $out5 = "Connection: close\r
  30. \r
  31. ";
  32. $out6 = "-----------------------------2\r
  33. ";
  34. $out7 = "Content-Disposition: form-data; name=\"onlinecheck\"\r
  35. \r
  36. ";
  37. $out8 = "\r
  38. -----------------------------2--";
  39.  
  40. //Calculation of the Content-Length:
  41. $tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8);
  42. $out4 = "Content-Length: $tlen\r
  43. ";
  44.  
  45. //Generate full output
  46. $out = $out1.$out2.$out3.$out4.$out5.$out6.$out7.$xmldata.$out8;
  47. fwrite($fp, $out);
  48. $retval = "";
  49. while(!feof($fp)){$retval = "$retval".fgets($fp,128);}
  50. fclose($fp);
  51. list($headers,$body) = explode("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",$retval);
  52. $doc = new DOMDocument();
  53. $doc ->LoadXML($body);
  54. $item_ids = $doc->getElementsByTagname( "OnlineCheck" );
  55. foreach( $item_ids as $item )
  56.  
  57.  {
  58.  $error_s = $item->getElementsByTagName( "Errorstatus" ); $tderror = $error_s->item(0)->nodeValue;
  59.  $stock_s = $item->getElementsByTagName( "AvailabilityTotal" ); $tdstock = $stock_s->item(0)->nodeValue;
  60.  $desc_s = $item->getElementsByTagName( "ProductDesc" ); $tddesc = $desc_s->item(0)->nodeValue;
  61.  $est_s = $item->getElementsByTagName( "EstimatedDeliveryQuantity" ); $tdestqty = $est_s->item(0)->nodeValue;
  62.  $estd_s = $item->getElementsByTagName( "EstimatedDeliveryDate" ); $tdestdate = $estd_s->item(0)->nodeValue;
  63.  $sku_s = $item->getElementsByTagName( "DistributorItemIdentifier" ); $tdsku = $sku_s->item(0)->nodeValue;
  64.  $manu_s = $item->getElementsByTagName( "ManufacturerItemIdentifier" ); $manu = $manu_s->item(0)->nodeValue;
  65.  
  66.  // Reformatting the price to ISO compatible format
  67.  $price_s = $item->getElementsByTagName( "UnitPriceAmount" ); $tdprice = $price_s->item(0)->nodeValue;
  68.  }
  69. //Process details under here
  70. echo "Supplier Part No: $tdsku \r
  71. Manuf Part No: $manu \r
  72. Product: $tddesc \r
  73. Stock: $tdstock \r
  74. Price: $tdprice";
  75. ?>
The above is what the suppliers sent me and I'm aware it's probably not the best way of doing it, but it (now) works. From "//Process details under here" is what I wrote to check it works.

Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2.  
  3. Dim myHTTP As MSXML2.xmlhttp
  4. Dim myDom As MSXML2.DOMDocument
  5. Dim qty, price, desc As MSXML2.IXMLDOMNode
  6. Dim myxml   As String
  7. sku = "1463230"
  8. manu = ""
  9.  
  10. Set myHTTP = CreateObject("msxml2.xmlhttp")
  11. Set myDom = CreateObject("MSXML2.DOMDocument")
  12.  
  13. myHTTP.Open "GET", "http://10x.0xx.0xx.xxx/c2000test.php?manu=" & manu & "&sku=" & sku, False
  14. myHTTP.send
  15.  
  16. MsgBox myHTTP.responseText, vbOKOnly, "Stock"
  17.  
  18. '   Set code = myHTTP.responseXML.selectSingleNode("//StockCheck/Price")
  19. '   MsgBox code
  20. Set myHTTP = Nothing
  21. End Sub
  22.  
The commented two lines near the bottom are what I'd like to be able to do, if at all possible.
Oct 10 '08 #3
mandanarchi
90 New Member
I've found the following code that chucks out xml; but it still doesn't let me select the nodes.

Expand|Select|Wrap|Line Numbers
  1. $output= "<Order>\r
  2. <sku>$tdsku</sku>\r
  3. <desc>$tddesc</desc>\r
  4. <stock>$tdstock</stock>\r
  5. <price>$tdprice</price>\r
  6. </Order>";
  7. $xmlDoc = new DOMDocument();
  8. $xmlDoc->LoadXML($output);
  9.  
  10. print $xmlDoc->saveXML();
When I say it chucks out xml, I mean it shows the text on a browser, but the source shows the full xml, tags included.
Oct 10 '08 #4
mandanarchi
90 New Member
Oh god.

I hate it when I'm so dense.

It was as simple as adding
Expand|Select|Wrap|Line Numbers
  1. header("Content-Type: text/xml");
to the top of the php.

thanks anyway guys =)
Oct 10 '08 #5
pbmods
5,821 Recognized Expert Expert
Glad to hear you got it working! Thanks for posting your solution!
Oct 10 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: manokumar | last post by:
hiye, i notice that some if not all of my folders in winxp pro. are set as read only and its giving me some problem with development. so as the natural thing, i unchecked the read only option and...
3
by: Hari Menon | last post by:
I am writing a C# client (using .NET 1.1) to a web service built on Apache Axis. The server returns an array using multirefs but the C# client does not seem to be able to recognize it. I read...
3
by: TomislaW | last post by:
I am sending word document with e-mail from asp.net 2.0 application. I read doc file like this:FileStream fs = System.IO.File.Open(docPath,FileMode.Open,FileAccess.Read,FileShare.Read); Then...
0
by: Mail Delivery Subsystem | last post by:
This is a multi-part message in MIME format. --TWXYZbcdeghijklnopqrsuvwxyz12345689ABCEF Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been...
0
by: MAILER-DAEMON | last post by:
This is a multi-part message in MIME format. --FLMNOQRSTUVXYZabcefghjklmnoqrstuvxyz0124 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit This message has been...
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...
1
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
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.