ERLEDIGT
NEIN
NEIN
ANTWORTEN
6
6
ZUGRIFFE
1827
1827
EMPFEHLEN
-
hi ich wuerde gerne von einer seite sagen wir mal google.de den quelltext in einem string speichern um dann spaeter den auszuwerten ich habe es mit system.xml versucht da bekomme ich aber leider nur die tags raus:
hier der code:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13
XmlTextReader reader = new XmlTextReader("http://www.google.de/"); while(reader.Read()) { switch(reader.NodeType) { case XmlNodeType.Element: Debug.WriteLine(string.Format("{0}", reader.Name)); break; } } reader.Close();
also bin fuer jeden code schnipsel dankbar und auch fuer aehnliche beispiele oder sowas.
gruss neral
-
Geht das nicht auch mit den HttpWebRequest / HttpWebResponse Klassen? Mit der GetResponse() Methode hättest du dann doch den Stream der vom Server zurückkommt...den kannst dann ja auswerten oder wegschreiben oder so.
Oder hab ich da was falsch verstanden?
-
urg jo stimmt danke thx hast mir echt weiter geholfen

aber irgendwie geht das nicht ganz koenntet ihr mal rueber schauen
habe ich die falschen klassen eingebunden ?PHP-Code:using System;
using System.Net;
namespace ConsoleApplication5
{
class Class1
{
static void Main(string[] args)
{
string url = "http://www.google.de";
//Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
// Releases the resources of the response.
myHttpWebResponse.Close();
// Releases the resources of the Stream.
readStream.Close();
/*HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com");
HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
// Insert code that uses the response object.
HttpWResp.Close();*/
}
}
}
oder was habe ich falsch gemacht ?!
gruss und thx nochmal.
-
27.08.04 14:30 #4
- Registriert seit
- Aug 2001
- Ort
- Österreich, Stmk, Graz
- Beiträge
- 2.783
Hallo.
Neral, bitte lies unsere Netiquette, beziehungsweise den roten Kasten unter dem Eingabefeld für Beiträge.
Bitte achte unbedingt auf Deine Rechtschreibung, eine klare Fragestellung bzw. Antwort und eine sinnvolle Struktur. Beiträge mit durchgehender Kleinschreibung, Chatsprache und/oder mangelhafter Struktur werden kommentarlos gelöscht.
Mehr dazu findest Du in unserer Netiquette.
Wenn du bei einem Code einen Fehler hast, zeig und auch bitte die Fehlermeldung, aber in deinem Fall, versuches es mal mit einem
bei den anderen Using-Anweisungen.Code :1 2
using System.IO; System.Text;
MfG,
AlexWith the first link the chain is forged. The first speech censored, the first thought forbidden, the first freedom denied, chains us all irrevocably.
Aaron Satie
Legends... are the spice of the universe, Mr. Data, because they have a way of sometimes coming true.
Captain Jean-Luc Picard, Stardate ~41294.5
Tutorials.de chattet. Hier gibts auch .net Support ^^
Klickt auf chattet und nutzt den Webchat, oder verbindet euch zu irc.tutorials.de - Channel #Tutorials.de
(moo)blog furred.net // SiteInfo für WP7 // Pastebin für WP7 // BlogEngine.net Extensions
-
Uii tut mir leid, diese roten Sachen habe ich nicht ganz gelesen
.
Also, ich habe das nun hinzugefuegt und jetzt kommt folgendes:
--------------------------------------------------------------------------------------------------------
C:\Dokumente und Einstellungen\Szymon\Eigene Dateien\Visual Studio Projects\ConsoleApplication1\Class1.cs(11):
Die beste Übereinstimmung für die überladene Methode 'string.String(char*)' hat einige ungültige Argumente
C:\Dokumente und Einstellungen\Szymon\Eigene Dateien\Visual Studio Projects\ConsoleApplication1\Class1.cs(11):
Argument '1': kann nicht von 'string' zu 'char*' konvertiert werden
C:\Dokumente und Einstellungen\Szymon\Eigene Dateien\Visual Studio Projects\ConsoleApplication1\Class1.cs(13):
Der Typ oder Namespace 'Response' konnte nicht gefunden werden. Möglicherweise fehlt eine Anweisung oder ein Assemblyverweis.
--------------------------------------------------------------------------------------------------------
Hier nochmal der Code:
PHP-Code:using System;
using System.Net;
using System.IO;
using System.Text;
namespace ConsoleApplication5
{
class Class1
{
static void Main(string[] args)
{
string url = "http://www.google.de";
//Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
// Releases the resources of the response.
myHttpWebResponse.Close();
// Releases the resources of the Stream.
readStream.Close();
/*HttpWebRequest HttpWReq = (HttpWebRequest)WebRequest.Create("http://www.contoso.com");
HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse();
// Insert code that uses the response object.
HttpWResp.Close();*/
}
}
}
-
27.08.04 19:48 #6bigo Tutorials.de Gastzugang
Ich hab mir mal den code kopiert und bei mir gehts!
Das Einzige was ich geändert habe ist eigentlich, dass ich URL als Uri deklariert habe:
Code :1
Uri URL = new Uri("www.google.de");
Hab mich extra angemolden um das zu posten, hoffe es hilft dir!
-
Hi SUPER!

Es geht nun. Aber nur zum Verstaendniss was ist Uri fuer eine Klasse ?!
hm.. wenn Ihr das ausfuehrt kommt bei Euch was in der Konsole als Ausgabe?,bei mir irgendwie nicht :\
Hier nochmal der Code, der sich ausfuehren laesst:
grussPHP-Code:using System;
using System.Net;
using System.IO;
using System.Text;
namespace ConsoleApplication5
{
class Class1
{
static void Main(string[] args)
{
Uri url = new Uri("http://www.google.de");
//Creates an HttpWebRequest with the specified URL.
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
// Sends the HttpWebRequest and waits for the response.
HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
// Gets the stream associated with the response.
Stream receiveStream = myHttpWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( receiveStream, encode );
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
// Reads 256 characters at a time.
int count = readStream.Read( read, 0, 256 );
Console.WriteLine("HTML...\r\n");
while (count > 0)
{
// Dumps the 256 characters on a string and displays the string to the console.
String str = new String(read, 0, count);
Console.Write(str);
count = readStream.Read(read, 0, 256);
}
Console.WriteLine("");
// Releases the resources of the response.
myHttpWebResponse.Close();
// Releases the resources of the Stream.
readStream.Close();
}
}
}
Ähnliche Themen
-
Textdatei auslesen und in String speichern
Von blong1550 im Forum C/C++Antworten: 4Letzter Beitrag: 14.01.10, 21:28 -
String auslesen und in ner Variable speichern
Von messmar im Forum Java GrundlagenAntworten: 1Letzter Beitrag: 05.05.08, 07:54 -
Brauche Shell script Hilfe - Dateinamen auslesen und sequenzen im string speichern
Von treki im Forum Linux & UnixAntworten: 3Letzter Beitrag: 04.06.07, 07:43 -
php quelltext mit php speichern
Von FJK im Forum PHPAntworten: 4Letzter Beitrag: 06.08.05, 13:56 -
Daten aus einer Datenbank auslesen und in String speichern
Von mserowiak im Forum .NET ArchivAntworten: 15Letzter Beitrag: 01.10.04, 16:43





Zitieren

Login





