sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
KathyB's Avatar

Possible to edit and save back certain nodes ONLY of an xmlDocument?


Question posted by: KathyB (Guest) on November 11th, 2005 10:49 PM
One more question...please.

I have an xml doc like this:

<assembly>
<station name="station1">
<wi id="1" name="doc231">
<boards>
<board sn="1111" start="07/15/03" end="07/16/03" />
<board sn="1112" start="07/15/03" end="07/16/03" />
</boards>
</wi>
<wi id="2" name="doc555">
<boards>
<board sn="1113" start="07/15/03" end="07/16/03" />
<board sn="1114" start="07/15/03" end="07/16/03" />
</boards>
</wi>
</station>
</assembly>

There are many <station> elements in the doc. This doc is saved as a
doc, not in a database.

Is it possible to have a user just edit one <station> and its
children/attributes then save those nodes back...can't picture
how...but I was hoping it was somehow possible...it is a doc that will
have access by multiple users and trying to figure out how to save all
the data.

Thanks,

Kathy
2 Answers Posted
Dino Chiesa [MSFT]'s Avatar
Dino Chiesa [MSFT] November 11th, 2005 10:49 PM
Guest - n/a Posts
#2: Re: Possible to edit and save back certain nodes ONLY of an xmlDocument?

yes, an application can modify just one of the elements in an xml doc, and
then save that to a file.

BUT, this will not work nicely if you are planning to have concurrent access
to the file. Example:
user1 starts app, loads XML file
user2 starts app, loads XML file
user1 modifies "station1" element
user2 modifies "station2" element
user1 saves file
user2 saves file

Then what will be in the file on the disk? Only the changes from user2. A
database can handle this sort of concurrent access. You can also do
something similar in a file but it takes some extra planning and coding.

How many users are involved? You might consider going to a database - it's
not that complicated and it's very nice for concurrent access.
And with MSDE, the license is free.



"KathyB" <KathyBurke40@attbi.com> wrote in message
news:75e8d381.0307161906.3c94622d@posting.google.c om...[color=blue]
> One more question...please.
>
> I have an xml doc like this:
>
> <assembly>
> <station name="station1">
> <wi id="1" name="doc231">
> <boards>
> <board sn="1111" start="07/15/03" end="07/16/03" />
> <board sn="1112" start="07/15/03" end="07/16/03" />
> </boards>
> </wi>
> <wi id="2" name="doc555">
> <boards>
> <board sn="1113" start="07/15/03" end="07/16/03" />
> <board sn="1114" start="07/15/03" end="07/16/03" />
> </boards>
> </wi>
> </station>
> </assembly>
>
> There are many <station> elements in the doc. This doc is saved as a
> doc, not in a database.
>
> Is it possible to have a user just edit one <station> and its
> children/attributes then save those nodes back...can't picture
> how...but I was hoping it was somehow possible...it is a doc that will
> have access by multiple users and trying to figure out how to save all
> the data.
>
> Thanks,
>
> Kathy[/color]


Kathy Burke's Avatar
Guest - n/a Posts
#3: Re: Possible to edit and save back certain nodes ONLY of an xmlDocument?

Thanks. I "mispoke" a bit. The xml tree IS in a database but in a string
in one field. So I can have a user READ the xml, manipulate his/her
"station" information, then retrieve the "current" string from the db,
make the revisions to the nodes, then save. Only one user should be
changing any given station at one time.

Given that, would you have an example/explanation of how to save back
(overwrite) an entire <station> element including all attributes and
children, etc.? I know how to get the individul nodes with xpath, etc.

versus saving the entire xml string back (because that would do as you
said...be missing information.

thanks again,

kathy

Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Not the answer you were looking for? Post your question . . .
196,809 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,809 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors