473,626 Members | 3,201 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to edit a value of an element in an XML document ?

Rob
First of all, I am using VB.net within the compact framework for programing
a PDA...

I am trying to modify the value of an item in an xml document...

The only samples I see use the doc.SelectNodes method. When I try using
this I get an error stating that "SelectNode s" is not a member of
'System.Xml.Xml Document'.

Can anyone post a sample of how you would change the value of an item in an
xml document (using only the subset of methods allowed by the compact
framework, if possible) ?

Or maybe just another way other than using "select nodes"

thanks !


May 22 '06 #1
7 1715


Rob wrote:
First of all, I am using VB.net within the compact framework for programing
a PDA...

I am trying to modify the value of an item in an xml document...

The only samples I see use the doc.SelectNodes method. When I try using
this I get an error stating that "SelectNode s" is not a member of
'System.Xml.Xml Document'.

Can anyone post a sample of how you would change the value of an item in an
xml document (using only the subset of methods allowed by the compact
framework, if possible) ?

Or maybe just another way other than using "select nodes"


According to the documentation the method GetElementsByTa gName is
supported in the .NET compact framework. The InnerText property is also
supported.
If you show us the structure of the XML you want to manipulate then we
can probably show you a code snippet to use.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 22 '06 #2
Rob
Hi Martin,

Yes, you are correct regarding ....
GetElementsByT agName is supported in the .NET compact framework. The
InnerText property is also supported.
However, "SelectNode s" does not appear to be supported..... which was the
method I sought to use.

I simply want to be able to change the value of the Delivered Tag to Yes.

<?xml version="1.0" encoding="UTF-8" ?>
- <AllOrders>
- <Order OrderId="123456 ">
<Route>1</Route>
<SalesOrder>123 456</SalesOrder>
<Customer>ABC </Customer>
<CustomerName>A lpha Company</CustomerName>
<ReqDeliveryDat e>5/27/2006</ReqDeliveryDate >
<Delivered>No </Delivered>
<Signed>No</Signed>
</Order>
- <Order OrderId="567890 ">
<Route>1</Route>

Thanks,
Rob

"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:u7******** ******@TK2MSFTN GP04.phx.gbl...

Rob wrote:
First of all, I am using VB.net within the compact framework for
programing a PDA...

I am trying to modify the value of an item in an xml document...

The only samples I see use the doc.SelectNodes method. When I try using
this I get an error stating that "SelectNode s" is not a member of
'System.Xml.Xml Document'.

Can anyone post a sample of how you would change the value of an item in
an
xml document (using only the subset of methods allowed by the compact
framework, if possible) ?

Or maybe just another way other than using "select nodes"


According to the documentation the method GetElementsByTa gName is
supported in the .NET compact framework. The InnerText property is also
supported.
If you show us the structure of the XML you want to manipulate then we can
probably show you a code snippet to use.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 22 '06 #3


Rob wrote:

I simply want to be able to change the value of the Delivered Tag to Yes.

<?xml version="1.0" encoding="UTF-8" ?>
- <AllOrders>
- <Order OrderId="123456 ">
<Route>1</Route>
<SalesOrder>123 456</SalesOrder>
<Customer>ABC </Customer>
<CustomerName>A lpha Company</CustomerName>
<ReqDeliveryDat e>5/27/2006</ReqDeliveryDate >
<Delivered>No </Delivered>
<Signed>No</Signed>
</Order>


foreach (XmlElement Order in
xmlDocument.Get ElementsByTagNa me("Order")) {
XmlElement Delivered = Order.GetElemen tsByTagName("De livered")[0]
as XmlElement;
if (Delivered != null) {
Delivered.Inner Text = "Yes";
}
}
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 22 '06 #4
Rob
Thanks Martin...

Is this easily converted to vb.net ?

"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:OM******** ******@TK2MSFTN GP02.phx.gbl...


Rob wrote:

I simply want to be able to change the value of the Delivered Tag to Yes.

<?xml version="1.0" encoding="UTF-8" ?>
- <AllOrders>
- <Order OrderId="123456 ">
<Route>1</Route>
<SalesOrder>123 456</SalesOrder>
<Customer>ABC </Customer>
<CustomerName>A lpha Company</CustomerName>
<ReqDeliveryDat e>5/27/2006</ReqDeliveryDate >
<Delivered>No </Delivered>
<Signed>No</Signed>
</Order>


foreach (XmlElement Order in
xmlDocument.Get ElementsByTagNa me("Order")) {
XmlElement Delivered = Order.GetElemen tsByTagName("De livered")[0] as
XmlElement;
if (Delivered != null) {
Delivered.Inner Text = "Yes";
}
}
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 22 '06 #5
Rob
Also, how would you specify only for SalesOrder number 123456 ?

Thanks !

"Rob" <rw*****@comcas t.net> wrote in message
news:Hv******** *************** *******@comcast .com...
Thanks Martin...

Is this easily converted to vb.net ?

"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:OM******** ******@TK2MSFTN GP02.phx.gbl...


Rob wrote:

I simply want to be able to change the value of the Delivered Tag to
Yes.

<?xml version="1.0" encoding="UTF-8" ?>
- <AllOrders>
- <Order OrderId="123456 ">
<Route>1</Route>
<SalesOrder>123 456</SalesOrder>
<Customer>ABC </Customer>
<CustomerName>A lpha Company</CustomerName>
<ReqDeliveryDat e>5/27/2006</ReqDeliveryDate >
<Delivered>No </Delivered>
<Signed>No</Signed>
</Order>


foreach (XmlElement Order in
xmlDocument.Get ElementsByTagNa me("Order")) {
XmlElement Delivered = Order.GetElemen tsByTagName("De livered")[0]
as XmlElement;
if (Delivered != null) {
Delivered.Inner Text = "Yes";
}
}
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


May 22 '06 #6


Rob wrote:
Also, how would you specify only for SalesOrder number 123456 ?


Here is a VB.NET example

Dim document As XmlDocument = New XmlDocument
document.Load(" file.xml")
For Each Order As XmlElement In
document.GetEle mentsByTagName( "Order")
Dim SalesOrder As XmlElement =
Order.GetElemen tsByTagName("Sa lesOrder")(0)
If Not SalesOrder Is Nothing And SalesOrder.Inne rText =
"123456" Then
Dim Delivered As XmlElement =
Order.GetElemen tsByTagName("De livered")(0)
If Not Delivered Is Nothing Then
Delivered.Inner Text = "Yes"
Exit For
End If
End If
Next
' save result, in this example to the console
' in reality to some file
document.Save(C onsole.Out)

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
May 23 '06 #7
Rob
Thanks Martin !
"Martin Honnen" <ma*******@yaho o.de> wrote in message
news:e3******** ******@TK2MSFTN GP03.phx.gbl...


Rob wrote:
Also, how would you specify only for SalesOrder number 123456 ?


Here is a VB.NET example

Dim document As XmlDocument = New XmlDocument
document.Load(" file.xml")
For Each Order As XmlElement In
document.GetEle mentsByTagName( "Order")
Dim SalesOrder As XmlElement =
Order.GetElemen tsByTagName("Sa lesOrder")(0)
If Not SalesOrder Is Nothing And SalesOrder.Inne rText =
"123456" Then
Dim Delivered As XmlElement =
Order.GetElemen tsByTagName("De livered")(0)
If Not Delivered Is Nothing Then
Delivered.Inner Text = "Yes"
Exit For
End If
End If
Next
' save result, in this example to the console
' in reality to some file
document.Save(C onsole.Out)

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/

May 23 '06 #8

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

Similar topics

15
10148
by: bengee | last post by:
Hi Does anyone know of a way to edit "live" javascript (that i have no control over) in IE? Example, i visit a website and see a webpage in IE containing Javascript. Can i edit that javascript and get IE to accept any changes i've done to it? So what i'm saying really, is that i want to hack the javascript served
12
4890
by: Anna | last post by:
Hi all, I posted the same question this afternoon but my message isn't showing up, so I thought I'd give it another try.... in case you should see it later I apologize for posting the same question twice! Here it is: I am having problems reading the value of a text Node. I think it has to do with the fact that the text is in a <span> tag. I have a table and in each <td> I have text + a checkbox. I want to retreive the text next to the...
8
2328
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3" ItemStyle-HorizontalAlign="center" ItemStyle-VerticalAlign="top"> <ItemTemplate><%# CType(Container.DataItem("DateStatut"),DateTime).ToString("yyyy-MM-dd") %></ItemTemplate> <EditItemTemplate> <asp:TextBox width="80" CssClass="edit_item" id="txtDateStatut"
21
3962
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
2
10685
by: Greg | last post by:
Hi. I have a rather large xml document (object) that can have one or more nodes with a certain attribute throughout (at ANY depth, not at the same level necessarily). I need to find this attribute and remove the containing node (and child nodes) if it has a certain value. I'm able to find the attributes using an XmlTextReader. Once found, can someone help me get the XPath at that point? I would then use this to remove the node from...
4
3709
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml file via some editable controls such as text boxes , option boxes etc. how can i implment this , should i use another xslt file with <INPUT> controls . if so how can i save the result back using the asp.net
20
6956
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
5
2948
by: WilliamRLinden | last post by:
Hi world! we are pretty new to JavaScript and have been struggling for now 2 days on this problem ... We would appreciate mercy if anyone can give us some. Basically we are trying to simulate the tab key when the down arrow key is pressed. (we know there are other way to control focus flow but we use a lot of dynamic jsp fields, that will make the flow control a nightmare, we just want basic tabbing from the arrow key)
2
2455
by: sowmram | last post by:
Hi, I'm trying to create a site very similar to wiki, where you can edit, save.. Generally update data for the future use... This particular program I wanna do it using javascripts... Please help me out in getting into the solution for the same... Sample prg which I hve done is as below... Looking forward for all of your help...Thanks in advance
0
8265
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7193
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4092
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.