473,395 Members | 2,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Update a specific XML node

Hi,

I have the following XML file :
<?xml version='1.0' encoding='UTF-8'?>
<Database>
<ConnectionString Type="PostgreSQL v8.2.x">
<DBName>c2st</DBName>
<Host>127.0.0.1</Host>
<Port>5432</Port>
<Username>user</Username>
<Password>pwd</Password>
</ConnectionString>
<ConnectionString Type="MySQL v4.x">
<DBName>dbtest</DBName>
<Host>127.0.0.1</Host>
<Port>5432</Port>
<Username>myuser</Username>
<Password>mypwd</Password>
</ConnectionString>
</Database>

How can i update only 1 particular node of this XML file without
browsing the whole nodes ?

for example, i would like to change <PortinnerXML value (5432) to 1258
for MySQL v4.x connection string.

All methods i've read till now are browsing the whole nodes and this i
would like to avoid as much as possible.

thanks a lot,

Alain
Aug 13 '07 #1
8 4443
On Aug 13, 7:50 am, "Alain R." <noem...@nospam.comwrote:

<snip>
How can i update only 1 particular node of this XML file without
browsing the whole nodes ?

for example, i would like to change <PortinnerXML value (5432) to 1258
for MySQL v4.x connection string.

All methods i've read till now are browsing the whole nodes and this i
would like to avoid as much as possible.
What exactly do you mean by "browsing the whole nodes"? The easiest
way is probably to use an XPath expression to find the element you
want, and then update it. However, I don't know whether that would
count as "browsing the whole nodes" in your view.

If you want to update the file, you'll have to rewrite the whole thing
though.

Jon

Aug 13 '07 #2
On Aug 13, 10:07 am, "Alain R." <noem...@nospam.comwrote:
I did that (see below) and it works well...i'm just scared when XMl file
will be huge.
So how big do you expect your files to be, and have you tested it with
a file that large?

It's better to have evidence under your belt than to be scared of
something that may not be a problem.

Jon

Aug 13 '07 #3
for now XML is les than 1 kb as i just started to work on it.

but i expect it will reach 600 kb.
Jon Skeet [C# MVP] wrote:
On Aug 13, 10:07 am, "Alain R." <noem...@nospam.comwrote:
>I did that (see below) and it works well...i'm just scared when XMl file
will be huge.

So how big do you expect your files to be, and have you tested it with
a file that large?

It's better to have evidence under your belt than to be scared of
something that may not be a problem.

Jon
Aug 13 '07 #4
On Aug 13, 10:35 am, "Alain R." <noem...@nospam.comwrote:
for now XML is les than 1 kb as i just started to work on it.

but i expect it will reach 600 kb.
600K is still relatively small. By the time it's loaded into memory it
will be significantly bigger of course, but unless you're loading and
saving thousands of these on a very frequent basis, I wouldn't expect
it to be a problem.

To be confident, however, you should see if you can create or find a
file of that size, and see how it performs.

Jon

Aug 13 '07 #5
Alain R. wrote:
for now XML is les than 1 kb as i just started to work on it.

but i expect it will reach 600 kb.
I think DOM in memory size typical is about 5 times on disk size.

In that case it is just 3 MB.

Arne
Aug 15 '07 #6
Arne Vajhøj <ar**@vajhoej.dkwrote:
It is not a 100 times.
So have you found the worst cases and measured it?
No - I don't really see any point in it.
If the worst case is known to be okay for the OP's situation, then
there's no need to try a representative file. Otherwise, however, it
*is* a good idea to try one.
You're assuming that *all* of the XML is like the sample posted. 600K
just of database connections is an awful lot - maybe there'll be other
data...
Sure.

But almost by definition I would expect that to be more close
to average than the worst case possible to create.
True - but without knowing how bad the worst case is, that's not much
comfort.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 18 '07 #7
Jon Skeet [C# MVP] wrote:
Arne Vajhøj <ar**@vajhoej.dkwrote:
>>You're assuming that *all* of the XML is like the sample posted. 600K
just of database connections is an awful lot - maybe there'll be other
data...
Sure.

But almost by definition I would expect that to be more close
to average than the worst case possible to create.

True - but without knowing how bad the worst case is, that's not much
comfort.
Why not. If real XML files are <10 it does not matter much if is
possible to construct an example with 17 or 27.

Arne
Aug 19 '07 #8
Arne Vajhøj <ar**@vajhoej.dkwrote:
Jon Skeet [C# MVP] wrote:
Arne Vajhøj <ar**@vajhoej.dkwrote:
>You're assuming that *all* of the XML is like the sample posted. 600K
just of database connections is an awful lot - maybe there'll be other
data...
Sure.

But almost by definition I would expect that to be more close
to average than the worst case possible to create.
True - but without knowing how bad the worst case is, that's not much
comfort.
Why not. If real XML files are <10 it does not matter much if is
possible to construct an example with 17 or 27.
But the point is that we didn't know what the genuine XML file would be
like. We hadn't experimented to find out *either* what it would be like
with real data *or* what a worst case would be. Using samples of other
XML files which may or may not be anything like the real one isn't
enough, IMO.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Earl Teigrob | last post by:
I am considering writing a Class that Selects, Adds, Updates and Deletes Nodes in an XML File but do not what to reinvent the wheel. (See XML file below) That data format would emulate records...
3
by: Rich Wallace | last post by:
Hi all, I've been though many posts in this group and have yet to find one that helps me understand how to accomplish my goal. I have an XML document that stores user specific values that I...
3
by: Ray | last post by:
I am having my first experience using BLOB as a row in a table. I am using it to insert graphics for labels we print. I have no problem inserting into and select from the table. The graphic is...
9
by: mike_li | last post by:
We are considering to update from V8.1 Fixpak 8 to Fixpak 9. Operating System Information: OSName: AIX NodeName: mdxxx01, mdxxx02, mdxxx03, mdxxx04 Version: 5 Release: 2 64 bits and DB2...
6
by: | last post by:
Hi, I'm steel trying to read and update my XML file with Visual Basic Express but i am unable to find the right way to read my xml file and update it if neccessary... Here is my problem :...
4
by: jackwootton | last post by:
Hello, Currently I use setInterval to call a function every 1.5 seconds. The function checks the content of 6 divs on a page. The content of each div is retrieved use innerHTML. If the...
3
by: traceable1 | last post by:
I installed the SQL Server 2005 SP2 update 2 rollup on my 64-bit server and the performance has tanked! I installed rollup 3 on some of them, but that did not seem to help. I thought it...
0
by: Falcula | last post by:
Hello, I have a treeview that i fill from a database, when i update nodename in database the treeview dont update. Its works when iam not useing enableviewstate="true" but then i loosing the...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.