Sign In/My Account | View Cart  
advertisement

Article:
 From JDOM to XmlDocument
Subject: Revised SearchForArtist() method
Date: 2002-04-05 07:29:15
From: Niel Bornstein
Response to: XPathNavigator

After a bit more research, here is another way to write the SearchForArtist() method. You'll notice that it does not use XPathNavigator directly, however it achieves the same result as my original code and is, I think, a little clearer to read.


public void SearchForArtist(string artist) {


XmlNode root = document.DocumentElement;


XmlNodeList nodeList = root.SelectNodes("//CD[@artist=normalize-space('" + artist + "')]");


Console.WriteLine("CDs by {0}:", artist);


foreach (XmlElement cd in nodeList) {


Console.WriteLine(" \"{0}\"", cd.GetAttribute("title"));


}


}


No Previous Message Previous Message Move up to Parent Message Up Next Message No Next Message


Sponsored By: