Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   XML (https://www.delphipraxis.net/46-xml/)
-   -   Delphi XML mit Indy download (https://www.delphipraxis.net/111790-xml-mit-indy-download.html)

bundy 9. Apr 2008 12:49


XML mit Indy download
 
Hi DP

ich versuche wie folgt einen XML File runterzuladen.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
myStream:TMemoryStream;
begin
try
myStream:=TMemoryStream.Create;

IdHTTP1.get('http://www.wowarmory.com/item-info.xml?i=21960',myStream);
myStream.Seek(0,soFromBeginning);
Memo1.Lines.LoadFromStream(myStream)

finally
  myStream.Free;
end;

end;
ich bekomm da aber kein XML file angezeigt.
sondern:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml-stylesheet type="text/xsl" href="/layout/item-info.xsl">
<html>
<head>
<link href="favicon.ico" rel="shortcut icon">
<title>The World of Warcraft Armory</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta content="The World of Warcraft Armory is a vast searchable database of information for World of Warcraft - taken straight from the real servers. It is the most comprehensive and up-to-date database on the characters, arena teams, guilds, items, dungeons, raids, bosses, and faction rewards of World of Warcraft in existence." name="description">
<script src="/shared/global/third-party/detection.js" type="text/javascript"></script>
<style media="screen, projection" type="text/css">
    @import "css/master.css";
   @import "css/en_us/language.css";
</style>
<script type="text/javascript">
//
if (is_moz) {
} else if (is_ie7) {
    document.write('<link rel="stylesheet" type="text/css" media="screen, projection" href="css/ie7.css" />');
}   
else if (is_ie6) {
    document.write('<link rel="stylesheet" type="text/css" media="screen, projection" href="css/ie.css" />');
Aber wenn ich im IExplorer auf rechte Maustaste gehe und Quelltext anzeigen drücke kommt das XML file
XML-Code:
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="/layout/item-info.xsl"?><page globalSearch="1" lang="de_de" requestUrl="/item-info.xml">
  <itemInfo>
    <item icon="inv_misc_horn_01" id="21960" level="1" name="Handgefertigte Schnitzerei" quality="1" type="Festtag">
      <reagentFor>
        <spell icon="temp" id="27708" name="Schachtel voller Holzschnitzereien von Darnassus herstellen">
          <item icon="inv_crate_01" id="22291" level="1" name="Schachtel voller Holzschnitzereien" quality="1" type="Festtag"/>
          <reagent count="4" icon="inv_misc_horn_01" id="21960" name="Handgefertigte Schnitzerei"/>
        </spell>
      </reagentFor>
    </item>
  </itemInfo>
</page>
wie bekomme ich das hin das er mir das XML File downloaded ?

lg
bundy

Helld_River 9. Apr 2008 13:28

Re: XML mit Indy download
 
hey,
das, was du im IE siehst ist das Ergebnis von XML mit XSL umgewandelt. Die XSL-Definition steht in der 2ten Zeile im Code, den dir das Programm mit Get liefert.

Ich denke am einfachsten ist es:
1.) TWebBrowser-Komponenet
2.) Navigate auf http://www.wowarmory.com/item-info.xml?i=21960
3.) Quellcode auslesen

Suche mal hier in der DP nach Beiträgen zu TWebbrowser, da solltest du alles finden.

Gruß, helld

bundy 9. Apr 2008 13:41

Re: XML mit Indy download
 
Danke für die Hilfe, aber ist es mit der Indy Komponente nicht möglich ?

bundy 9. Apr 2008 15:04

Re: XML mit Indy download
 
Wenn ich das mit der Webborwser Komponente mache erhalte ich das selbe.
Wie wandle ich das um ?

Helld_River 9. Apr 2008 15:53

Re: XML mit Indy download
 
sorry, war mein Fehler, habe das gerade auch noch mal ausprobiert.

OK, dann gehen wir die Sache mal anders an:

Was genau soll das Ergebnis deiner Arbeit sein ? Was willst du erreichen ?

gruß, helld

bundy 9. Apr 2008 16:19

Re: XML mit Indy download
 
ich will von der World of Warcraft Seite (http://eu.wowarmory.com/item-info.xml?i=29040) das XML Files Auslesen, das sind die Daten des Items,und in meinem Client (Programm) darstellen.

Helld_River 9. Apr 2008 18:23

Re: XML mit Indy download
 
so, hab es nun hinbekommen:

1.) Button, Memo, und WebBrowser auf ein Form legen
2.)
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var doc : OleVariant;
begin

  WebBrowser1.Navigate('http://www.wowarmory.com/item-info.xml?i=21960');
  while WebBrowser1.ReadyState <> READYSTATE_COMPLETE do
  begin
    Application.ProcessMessages;
  end;
  //Daten auslesen
  doc := Webbrowser1.Document;
  Memo1.Lines.Text:=doc.XMLDocument.XML;
end;
Die Idee ist von Marabu: TWebBrowser Sourcecode auslesen


Viel Spaß damit !

Gruß, helld

PS.: Würde mich mal interessieren, was draus geworden ist, wenn es fertig ist ;)

bundy 9. Apr 2008 18:35

Re: XML mit Indy download
 
hi , ich hab inzwischen auch ne lösung gefunden,

folgende
Delphi-Quellcode:
uses
MSXML

procedure TForm1.Button2Click(Sender: TObject);
var
mydoc:IXMLDOMDocument;
begin
mydoc:= CoDOMDocument.Create;
mydoc.async:=false;
 mydoc.load('http://eu.wowarmory.com/item-info.xml?i=29040') ;

 Memo1.Text:=mydoc.xml;

end;
Das funktioniert soweit sehr gut, nur hab ich das problem, das die Item sprache auf (lang=us_en) ist siehe:
XML-Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="/layout/item-info.xsl"?>
<page globalSearch="1" lang="en_us" requestUrl="/item-info.xml">
   <itemInfo>
      <item icon="inv_helmet_15" id="29040" level="120" name="Cyclone Helm" quality="4" type="Mail">
         <cost>
            <token count="1" icon="inv_helmet_24" id="29760"/>
         </cost>
         <disenchantLoot requiredSkillRank="300">
            <item dropRate="6" icon="inv_enchant_voidcrystal" id="22450" level="70" maxCount="2" minCount="1" name="Void Crystal" quality="4" type="Enchanting"/>
         </disenchantLoot>
         <vendors>
            <creature area="Terokkar Forest" classification="0" id="20616" maxLevel="64" minLevel="64" name="Asuur" title="Keeper of Sha'tari Artifacts" type="Humanoid"/>
            <creature area="Terokkar Forest" classification="0" id="20613" maxLevel="64" minLevel="64" name="Arodis Sunblade" title="Keeper of Sha'tari Artifacts" type="Humanoid"/>
         </vendors>
      </item>
   </itemInfo>
</page>
über den Webborwser bekomme ich bei lang="de_de" und dann auch die Stat´s auf deutsch.

Teste es gleich mal mit deiner Methode.
Hast du vieleicht eine Ahnung wie ich diese Parameter setzen kann damit ich das auf German zurück bekomme das xml file?

lg
bundy

bundy 9. Apr 2008 18:38

Re: XML mit Indy download
 
cool deine lösung ist auf deutsch :thumb: danke
Weist du vieleicht noch wie ich das bei meiner Methode bewerkstelligen könnte mit den Parametern, weil da würde ich nicht den ganzen Grafischen anhang mitladen.

lg bundy

Namenloser 9. Apr 2008 18:59

Re: XML mit Indy download
 
Ich denke mal, du müsstest im Request-Header die Sprache mitsenden. Weiß nicht wie das geht, aber das müsste sich sicher finden lassen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:56 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz