Article View: alt.pl.comp.lang.csharp
Article #22435Re: Jak parsować dokument xml zapisany w xmlu?
From: Paweł
Date: Sun, 09 Sep 2012 13:59
Date: Sun, 09 Sep 2012 13:59
51 lines
3031 bytes
3031 bytes
Użytkownik "Łukasz 'Maly' Ostrowski" <l3vi4than@USUNgmail.com> napisał w
wiadomości news:flur8qj0574w$.vewro493o4xg$.dlg@40tude.net...
> On Sun, 9 Sep 2012 11:01:49 +0200, Paweł wrote:
>
>> Witam
>> Chciałbym poprosić o małą podpowiedź jak można parsować w C# dokument
>> xml,
>> który posiada wiele dokumentów xml (tyle ile rekordów w tabeli bazy
>> danych)
>> zapisanych w postaci tekstowej (utf-8) tzn. znaczki tagów są w postaci
>> <>
>> <snip>
>> Chodzi o wydobycie danych zapisanych jako tekst.
>> Z góry dziękuję za pomoc i pozdrawiam Paweł
>
> To może być niespodziewane ale:
> http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx
> ;-).
>
> --
> Pozdrawiam,
> Łukasz 'Maly' Ostrowski. http://l3v.pl/
Pierwszy z brzegu kod wykrzacza się na polskich znakach i zonk ;-(
public static void Main(string[] args)
{
// Create an XmlUrlResolver with default credentials.
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;
// Point the resolver at the desired resource and resolve as a
stream.
Uri baseUri = new Uri("C://tmp//xml//");
//Uri fulluri = resolver.ResolveUri(baseUri, "Tab_XR_to_XML.xml");
Uri fulluri = resolver.ResolveUri(baseUri, "rekordy.xml");
Stream s = (Stream)resolver.GetEntity(fulluri, null,
typeof(Stream));
// Create the reader with the resolved stream and display the data.
XmlReader reader = XmlReader.Create(s);
while (reader.Read())
{
Console.WriteLine(reader.ReadOuterXml());
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
Technical Details
Message-ID:
<504ca7ed$0$1219$65785112@news.neostrada.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mailReferences:
<504c5bb4$0$1311$65785112@news.neostrada.pl> <flur8qj0574w$.vewro493o4xg$.dlg@40tude.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.neostrada.pl!unt-exc-01.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail From: Paweł <gamacdur@op.pl> Newsgroups: alt.pl.comp.lang.csharp References: <504c5bb4$0$1311$65785112@news.neostrada.pl> <flur8qj0574w$.vewro493o4xg$.dlg@40tude.net> In-Reply-To: <flur8qj0574w$.vewro493o4xg$.dlg@40tude.net> Subject: Re: Jak parsować dokument xml zapisany w xmlu? Date: Sun, 9 Sep 2012 15:59:17 +0200 MIME-Version: 1.0 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 X-EsetScannerBuild: 12026 Lines: 52 Message-ID: <504ca7ed$0$1219$65785112@news.neostrada.pl> Organization: Telekomunikacja Polska NNTP-Posting-Host: 83.6.5.111 X-Trace: 1347201006 unt-rea-b-01.news.neostrada.pl 1219 83.6.5.111:50432 X-Complaints-To: abuse@news.neostrada.pl X-Received-Bytes: 2892 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit