473,473 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Editing xml

Hi i m having trouble saving xml file .
Dim mxnode As XmlNode
Dim xElem As XmlElement
Dim xDoc As New XmlDocument()
xDoc.Load("PingAddress.xml")

Me.LoadXMLFromFile()

mxnode = xDoc.SelectSingleNode("//Item[@ID='one1']")

mxnode = mxnode.ChildNodes.Item(2) ' i need to go
to the DownTime of item one1(refer below) any

' other way

xElem = CType(mxnode, XmlElement)
xElem.InnerText = Date.Now ' here i
change the date to now but when i open the xml file its
not

changed

Heres the format of the xml file

<?xml version="1.0"?>
<Ping>
<Class Name="one">
<Item ID="one1">
<Name>one 1</Name>
<Address>10.205.4.1</Address>
<DownTime>13/02/2007 20:51:08</DownTime>
</Item>
<Item ID="Two2">
<Name>Two 2</Name>
<Address>10.205.4.1</Address>
<DownTime></DownTime>
</Item>
</Class>
</Ping>

Feb 13 '07 #1
3 1422
You must save your XML at the end.

Use xDoc.Save(); and then check your file and you'll see the updates.

--

Tiago Salgado

http://weblogs.pontonetpt.com/tiagosalgado
http://www.foruns.org
http://www.portugal-a-programar.org
http://www.revista-programar.info

"Deepak" <de*********@gmail.comwrote in message
news:11**********************@k78g2000cwa.googlegr oups.com...
Hi i m having trouble saving xml file .
Dim mxnode As XmlNode
Dim xElem As XmlElement
Dim xDoc As New XmlDocument()
xDoc.Load("PingAddress.xml")

Me.LoadXMLFromFile()

mxnode = xDoc.SelectSingleNode("//Item[@ID='one1']")

mxnode = mxnode.ChildNodes.Item(2) ' i need to go
to the DownTime of item one1(refer below) any

' other way

xElem = CType(mxnode, XmlElement)
xElem.InnerText = Date.Now ' here i
change the date to now but when i open the xml file its
not

changed

Heres the format of the xml file

<?xml version="1.0"?>
<Ping>
<Class Name="one">
<Item ID="one1">
<Name>one 1</Name>
<Address>10.205.4.1</Address>
<DownTime>13/02/2007 20:51:08</DownTime>
</Item>
<Item ID="Two2">
<Name>Two 2</Name>
<Address>10.205.4.1</Address>
<DownTime></DownTime>
</Item>
</Class>
</Ping>

Feb 14 '07 #2
You must save your XML at the end.
>
Use xDoc.Save(); and then check your file and you'll see the updates.

I did that but it asks for the parameter of file name (there are three
others )
xdoc.save() needs a parameter

I tried
xDoc.Save("PingAddress.xml") trying to overwrite the file and it
works . Is it necessary to give the file name ?

Feb 14 '07 #3
Yes.

I think that you are assuming that the XmlDocument has a relationship with
the file it was loaded from.

This is NOT the case.

When you execute xDoc.Load(<filename>), the contents of the file are parsed
and loaded into the instance of the XmlDocument. When that is complete the
XmlDocument object does not retain any knowledge about where it was 'loaded'
from.
"Deepak" <de*********@gmail.comwrote in message
news:11*********************@s48g2000cws.googlegro ups.com...
>You must save your XML at the end.

Use xDoc.Save(); and then check your file and you'll see the updates.


I did that but it asks for the parameter of file name (there are three
others )
xdoc.save() needs a parameter

I tried
xDoc.Save("PingAddress.xml") trying to overwrite the file and it
works . Is it necessary to give the file name ?
Feb 14 '07 #4

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

Similar topics

4
by: Dan Weeb | last post by:
Hi All, I have struggled through this far with help from many of you so thanks. I am stuck again. I am really new to this so don't be harsh :-) There are a few problems. You can run the script...
3
by: Dirk Rudolf | last post by:
I like to announce you the product X2U, avaible under http://www.lumrix.net/x2. X2U is an acronym for "XML to user". Existing XML editors still ignore the fact that users don't want to read XML...
1
by: nospam | last post by:
Amazon wins patent for ordering forms, Collapsing and Maximizing Form Areas.... NAME OF PATENT Method and system for displaying and editing of information # 6,615,226 ...
10
by: David T. Ashley | last post by:
Hi, I'd like to do some basic graphics. For example, if you look at: http://www.marshallaviationcenter.com the banner graphics at the top that apparently used an image editor with some...
2
by: NewBob | last post by:
Since Access automatically highlights all of the text in a text control (I use it to hold data from a memo field) when the control is activated, I've added the following code to put the cursor at...
1
by: AndrewDucker | last post by:
I've just started working with some people that have an odd setup and I'm wondering if someone can point out a better way of doing things (or what I'm doing wrong). They have a base form class,...
3
by: Islamegy | last post by:
When i press btn_save all changed rows in my grid get saved except the last editing row... I want my btn_Save to end editing in the datagrid.. so if user didn't press "enter" after editing last...
3
by: Tina | last post by:
Does anyone know of an asp.net general purpose table editing tool that will allow users to add modify and delete data? Thanks, T
12
by: Thomas Bartkus | last post by:
Does anyone use emacs together with both WordStar key bindings and python mode? I'm afraid that Wordstar editing key commands are burned R/O into my knuckles! I would like to play with emacs...
9
by: pvsundarram | last post by:
hey, i am trying to cancel the keydown event for certain keycodes( for eg:- enter key ).But the cancelling of this event is not happening in firefox. Is there any way to cancel the event in the...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.