🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.pl.comp.lang.csharp
4 messages
4 total messages Started by Krzysztof Wed, 15 Oct 2003 20:17
Bieganie po XML jak po bazie :)
#144
Author: Krzysztof
Date: Wed, 15 Oct 2003 20:17
13 lines
1384 bytes
Hi all,
wlasciwie to lenistwo, ale szukam najprostrzej alternatywy
mam dokumnet XML, i pobieram z niego elementy poprzez petle iteracyjne po
"nodes" i szukanie okre�lonego elementu. Ale o ile dobrze pamietam to mozna
bylo to zrobic inaczej. i nie wiem czy przez XPath, czy XmlDocument, dosc ze
pamietam taki fragment:

XmlNode xn = XmlDoc.select("\\settings\\admin\\pass");

czy ktos to pamieta?

pozdrawiam
Krzysztof
Re: Bieganie po XML jak po bazie :)
#145
Author: 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? ;)
Re: Bieganie po XML jak po bazie :)
#146
Author: Marcin Hoppe
Date: Sun, 19 Oct 2003 18:33
6 lines
1232 bytes
"Krzysztof" <kkdi...@poczta.onet.pl> wrote in message
news:bmuf70$8o7$1@news.onet.pl...
> PS. Ludzie ktos tu oprocz mnie bywa? ;)

    Ja. Ale teraz nie piszę nic w C#, więc moja aktywność w tym temacie jest
niewielka.
Re: Bieganie po XML jak po bazie :)
#147
Author: Mirosław Pragłowski
Date: Mon, 20 Oct 2003 20:15
7 lines
1144 bytes
> PS. Ludzie ktos tu oprocz mnie bywa? ;)

Ostatnio wszyscy na DevDaysach byli ;))


-- 
Mirek
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads