🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #145

Re: Bieganie po XML jak po bazie :)

#145
From: Krzysztof
Date: Sun, 19 Oct 2003 16:46
54 lines
2422 bytes
[ciach wszystko bo moje]
a jednak znalazlem...
polecam kopalnie wiedzy na CodeProject (www.codeproject.com)

Fragment XML:
<?xml version="1.0" standalone="yes"?>
<Root>
  <Region>
    <RegionID>1</RegionID>
    <RegionDescription>Reeeeeaalllly Far East!</RegionDescription>
  </Region>
  <Region>
    <RegionID>2</RegionID>
  .....

wyszukany fragment kodu przeszukujacego (nie jest to bezposrednio XPath, ale
tez sie nadaje) :
---------------------------------------------------------
using System;
using System.Data;
using System.Xml;

namespace Wrox.ProDotNet.Chapter10.XPath_XmlDataDocument
{
class ClassMain
{
static void Main(string[] args)
{
   DataSet RegionDS = new DataSet();
   DataRow RegionRow;
   RegionDS.ReadXmlSchema( " Region_More.XSD" );
   XmlDataDocument DataDoc = new XmlDataDocument( RegionDS );
   DataDoc.Load( " Region_More.XML" );
   // Now we'll select all of the regions that have
   // a RegionID > 2.
   XmlNodeList NodeMatches =
          DataDoc.SelectNodes("//Root//Region[@RegionID>2]");

   Console.WriteLine( "------------------------" );

   foreach ( XmlNode tmpNode in NodeMatches )
   {
      // pull up corresponding row in the DS.
      RegionRow = DataDoc.GetRowFromElement( (XmlElement)tmpNode );
      Console.WriteLine(RegionRow["RegionDescription"]);
   }

}
}
}

Pozdrawiam
Krzysztof
PS. Ludzie ktos tu oprocz mnie bywa? ;)
Technical Details
Message-ID: <bmuf70$8o7$1@news.onet.pl>
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-stoc.telia.net!news-stoa.telia.net!telia.net!news.nask.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
References: <bmka15$dtv$1@news.onet.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-stoc.telia.net!news-stoa.telia.net!telia.net!news.nask.pl!newsfeed.gazeta.pl!news.onet.pl!not-for-mail
From: "Krzysztof" <kkdi...@poczta.onet.pl>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: Bieganie po XML jak po bazie :)
Date: Sun, 19 Oct 2003 18:46:59 +0200
Organization: news.onet.pl
Lines: 56
Sender: kkdiesel@poczta.onet.pl@195.205.44.75
Message-ID: <bmuf70$8o7$1@news.onet.pl>
References: <bmka15$dtv$1@news.onet.pl>
NNTP-Posting-Host: 195.205.44.75
X-Trace: news.onet.pl 1066582048 8967 195.205.44.75 (19 Oct 2003 16:47:28 GMT)
X-Complaints-To: ab...@onet.pl
NNTP-Posting-Date: 19 Oct 2003 16:47:28 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit