HELP!
Using VB.NET, VS2003, XML. I apologize for the length of this request.
Though I've written before and received advise pointing to several articles
(which I've read and re-read), frankly, I'm still confused and need help!
My request might be a little different than what XML procedures appear to be
directed towards (ie, wholesale transformations or mass updates). What I need
to do is to selectively locate specific book titles and edit information in a
another field of the book's data.
Here is a simplified view of the XML file. It represents data for two
specific books. The document root is <mrcbfile>. The node for specific books
(with attribute) is <mrcb format-type="bd">. Each book node has several
childnodes, although I've only included a few for this example (capitalized
nodes are the important ones):
<mrcbfile>
<mrcb format-type="bd">
<mrcb-control-fields>
<mrcb008-bk>
<mrcb008-bk-00-05 value="020718"/>
</mrcb008-bk>
</mrcb-control-fields>
<MRCB-TITLE-AND-TITLE-RELATED>
<mrcb245 i1="i1-1" i2="i2-4">
<mrcb245-a>The fat girl</mrcb245-a>
<mrcb245-c>Marilyn Sachs.</mrcb245-c>
</mrcb245>
</mrcb-title-and-title-related>
<MRCB-NOTES>
<mrcb520 i1="i1-blank" i2="i2-blank">
<mrcb520-a>Jeff, a high school senior, becomes obsessed with creating a
beautiful person.</mrcb520-a>
</mrcb520>
</mrcb-notes>
<MRCB-NOTES>
<mrcb596 i1="i1-blank" i2="i2-blank">
<mrcb596-a>1</mrcb596-a>
</mrcb596>
</mrcb-notes>
</mrcb> <mrcb format-type="bd">
<mrcb-control-fields>
<mrcb008-bk>
<mrcb008-bk-00-05 value="020718"/>
</mrcb008-bk>
</mrcb-control-fields>
<MRCB-TITLE-AND-TITLE-RELATED>
<MRCB245 i1="i1-1" i2="i2-2">
<MRCB245-A>A pocket full of seeds </mrcb245-a>
</mrcb245>
</mrcb-title-and-title-related>
<MRCB-NOTES>
<mrcb520 i1="i1-blank" i2="i2-blank">
<mrcb520-a>Nicole's parents thought they would have enough time to
escape from the Nazis.</mrcb520-a>
</mrcb520>
</mrcb-notes>
<MRCB-NOTES>
<MRCB590 i1="i1-blank" i2="i2-blank">
<MRCB590-A>Quiz owned by: FOREST, NEILL</mrcb590-a>
</mrcb590>
<MRCB590 i1="i1-blank" i2="i2-blank">
<mrcb590-a>Quiz owned by: FOREST, NEILL</mrcb590-a>
</mrcb590>
</mrcb>
</mrcbfile>
What I need to do:
1. Navigate to/select a book (/<mrcb>) and check the book's title (at
/<mrcb>/<mrcb-title-and-title-related>/mrcb245/mrcb245-a)
2. If the title matches my compare string, I need to look for the books'
note tag
<mrcb590>/<mrcb590-a> which contains the text "Quiz owned by..." and
add a name to the end of the list. Not all books have the 590 tag.
3. Repeat steps 1 and 2 for every other book in the file.
PROBLEMS
1. I've tried using xpath and DOM, building nodelists to look into. But when
I build a reference to the book node, I get stuck on how to navigate through
each child and "grand-child" to find the title and notes descendants of that
node so I can change the Notes text. I've tried to create nexted "for each
loops" (as I would normally use), based on additional nodelists set to
deeper levels, but they don't seem to be connected to the main loop, making
unforeseen changes.
2. I'm thinking that, once I locate the first node (the first book), I will
need
to clone the node so that I can navigate through it without changing the
original current node location. But I'm stuck on how this all should be coded.
3. In short, I can locate the first level node, but I'm stuck on how to
properly drill down to the descendants of each node to make changes, without
losing my place.
REQUEST
I'm frustrated and desperate. Can somebody give me a bit of (pseudo or real
)code to show how the best way to navigate through the books <mrcb>, look for
a specific book title <mrcb245-a> and if found, append/edit text to any (and
all) 590-a text descendants ("QUiz owned by...") of that node.
I've read every articles I can find on xml, xpath, doc, navigator, etc. And
I admit it - I'm frustrated and desperate. It must be so blindingly obvious,
I'm not seeing it (shades of Edgar Allen Poe).
Thanks a million in advance!
George