Thanks for the refs and examples! I actually have waded through these before;
and other searching methods. Which is to say, I was over my head. I also
appreciate the sample code, which is easy to understand, by the way.
of an element. Rather, I have to search for specific book titles within the
collection and update a related quiz field for that book. In XML terms, I
offers more contextual help and examples, as well.
"Yingzi Le" wrote:
> Hi Geoge,
>
> I'd suggest you use Xml DOM and XmlElement. Take a look at these
> documentations:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemxmlxmldocumentmemberstopic.asp
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemxmlxmlelementmemberstopic.asp
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemxmlxmlelementclasssetattributetopic.asp
>
> You can do something like this(This is C# sintax, VB syntax is similar):
>
> XmlDocument xmlDoc = new XmlDocument();
> XmlTextReader reader = new XmlTextReader("C:\temp\booklist.xml");
> reader.XmlResolver = null;
> xmlDoc.Load(reader);
>
> //get all the book nodes using XPath
> XmlNodeList bookNodes = xmlDoc.SelectNodes("//book");
>
> //Iterate each book nodes
> foreach (XmlElement book in bookNodes)
> {
> //your test statements
> //you can update the //book attributes and element
> book.SetAttributes("ISBN", <new value here>);
> //get child Element
> XmlElement info = book.SelectSingleNode("./info");
> }
>
> Assume from the following XML file:
>
> <BookList>
> <book ISBN="">
> <title/>
> <authors><author/></authors>
> <info/>
> ................
> <book>
> </BookList>
>
> Hope this helps!
> --Yingzi Le
> LongHorn SDK Team
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> --------------------
> >Thread-Topic: newbie question on finding and editing
> >thread-index: AcUG8pb67494fsO0SOW2EUmyW6puzQ==
> >X-WBNR-Posting-Host: 63.231.157.145
> >From: =?Utf-8?B?R2VvcmdlQXRraW5z?= <GeorgeAtkins@discussions.microsoft.com>
> >Subject: newbie question on finding and editing
> >Date: Sun, 30 Jan 2005 09:39:03 -0800
> >Lines: 11
> >Message-ID: <586DEDB9-157F-4CFB-9921-B00D1EA23AF9@microsoft.com>
> >MIME-Version: 1.0
> >Content-Type: text/plain;
> > charset="Utf-8"
> >Content-Transfer-Encoding: 7bit
> >X-Newsreader: Microsoft CDO for Windows 2000
> >Content-Class: urn:content-classes:message
> >Importance: normal
> >Priority: normal
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> >Newsgroups: microsoft.public.dotnet.xml
> >NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
> >Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
> >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.xml:25160
> >X-Tomcat-NG: microsoft.public.dotnet.xml
> >
> >Using vb.net, I need to search through XML files to locate specific
> elements
> >and once found, update attributes of their companion elements. In plain
> >language, I need to find specific book titles and update note information
> >about each book. Not every book would be updated; just selected ones.
> >
> >So, I am confused whether to use DOM, XPath, both, or something else? My
> >understandig of Xpathnavigator is that it is a read-only class. And DOM
> seems
> >good for mass updates, but how to use it to find things? Thanks for any
> >advise!
> >
> >george
> >
>
>
>