473,380 Members | 1,424 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,380 software developers and data experts.

Change returned data content type?

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
Oct 10 '08 #1
5 1346
5,821 Expert 4TB
Heya, Mandi.

Which programming language are you using? That doesn't look like PHP.
Oct 10 '08 #2
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'];
  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>";
  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--";
  40. //Calculation of the Content-Length:
  41. $tlen=strlen($out6)+strlen($out7)+strlen($xmldata)+strlen($out8);
  42. $out4 = "Content-Length: $tlen\r
  43. ";
  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 )
  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;
  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()
  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 = ""
  10. Set myHTTP = CreateObject("msxml2.xmlhttp")
  11. Set myDom = CreateObject("MSXML2.DOMDocument")
  13. myHTTP.Open "GET", "http://10x.0xx.0xx.xxx/c2000test.php?manu=" & manu & "&sku=" & sku, False
  14. myHTTP.send
  16. MsgBox myHTTP.responseText, vbOKOnly, "Stock"
  18. '   Set code = myHTTP.responseXML.selectSingleNode("//StockCheck/Price")
  19. '   MsgBox code
  20. Set myHTTP = Nothing
  21. End Sub
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
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);
  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
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
5,821 Expert 4TB
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

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...
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...
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...
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...
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...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.