Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Oct : Re: Use Internetwrite to append to a web site file?
| Subject: | Re: Use Internetwrite to append to a web site file? |
| Posted by: | "Joe H" (joedot..@att.net) |
| Date: | 5 Oct 2007 07:25:05 |
Eddie Shipman wrote:
> I see, then it is very easy to do in your app. If you make your file
> XML, then you can easily use XMLHTTPRequest .vs WinInet to do this
> kind of thing. It is easier to work with. Here's an example of
> getting an XML file from a website using it:
>
> uses ..., MSXML2_TLB, COmObj;
>
> function ValidSerial(ASerialNum: String): String;
> var
> oXMLDoc: IXMLDOMDocument2;
> oXMLHTTP: IXMLHTTPRequest;
> oSerialNode: IXMLDOMNode;
> begin
> oXMLDoc := CreateOleObject('MSXML2.DOMDocument.3.0') as
> IXMLDOMDocument2;
> oXMLHTTP := CreateOleObject('MSXML2.XMLHTTP') as IXMLHTTPRequest;
> try
> oXMLHTTP.open('GET', 'URL', False, '', '');
> oXMLHTTP.send(EmptyParam);
> // The ResponseText contains the XML returned from the GET
> oXMLDoc.LoadXML(oXMLHTTP.ResponseText);
> // Parse the XML for the current serial number to see if it
> exists. //
> // The serial code would be in a node defined like this in this
> example:
> // <Serial-0123-4567-8901-2345>Bad
> Check</Serial-0123-4567-8901-2345>
> //
> oSerialNode := oXMLDoc.selectSingleNode('//Serial-'+ASerialNum);
> if oSerialNode <> nil then
> Result := oSerialNode.Text
> else
> Result := '';
> finally
> oXMLDoc := nil;
> oXMLHTTP := nil;
> end;
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
> Label1.Caption := ValidSerial(Edit1.Text);
> end;
>
> Example XML file:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <BadSerials>
> <!--
> Nodename MUST begin with an Alpha char
> Reason is in the Node.Text
> -->
> <Serial-0123-4567-8901-2345>Bad Check</Serial-0123-4567-8901-2345>
> <Serial-4567-8901-2345-0123>Charge Back</Serial-4567-8901-2345-0123>
> </BadSerials>
Interesting. Thanks for the feedback. I had not seen those elements in
xml. I think the WinInet code is simpler and less code. With XML the
bad serial file on the web would be much larger and the xml data would
be visible to search engines and anyone else. I see I could hash the
serial numbers but still the xml framework is far larger than what I'm
doing now. I looked at the xml source files in d2005 and it's a ton of
overhead and that has not changed as of d2007. The end result is far
larger than nearly any other way of storing information. I guess the
idea behind xml is to document data independent of it's originating
program and I see that everyone is doing it but I personally find it
hard to justify in tightly focused programs. I just don't see the
benefits over simple tables and even ini files.
-
none