SORU
13 Mart 2009, Cuma


Nasıl ve C XML dosyası okuma ayrıştırma mı#?

Nasıl ve C XML dosyası okuma ayrıştırma mı#?

CEVAP
13 Mart 2009, Cuma


XmlDocument dosyadan string veya XML okumak.

XmlDocument doc = new XmlDocument();
doc.Load("c:\\temp.xml");

ya

doc.LoadXml("<xml>something</xml>");

bu gibi yani altında bir düğüm

XmlNode node = doc.DocumentElement.SelectSingleNode("/book/title");

ya

foreach(XmlNode node in doc.DocumentElement.ChildNodes){
   string text = node.InnerText; //or loop through its children as well
}

o zaman bu gibi düğüm içindeki metni okuyun

string text = node.InnerText;

veya bir özniteliği okunamadı

string attr = node.Attributes["theattributename"].InnerText

Her zaman Öznitelikleri null için kontrol edin [eğer özniteliği yoksa NOT null olacak beri."bir şey"]

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Google

    Google

    18 EYLÜL 2005
  • Muse

    Muse

    28 EYLÜL 2006
  • Tips On Linux

    Tips On Linu

    26 Temmuz 2008