Beginners Question...

I got a XML file like this:

<?xml version="1.0" encoding="utf-16"?>
<LicenceControlFile>
  <Licence1>2AB7-FA43-B05C-4C2A-8DBD</Licence1>
  <MachineName />
  <Licence2>2AB7-FA43-B05C-4C2A-8DBD</Licence2>
  <MachineName />
  <Licence3>2AB7-FA43-B05C-4C2A-8DBD</Licence3>
  <MachineName />
 </LicenceControlFile>

Now i need to set the Value of one of the  <MachineName /> Elements !
How can i do this with .NET...

Thanks

Peter


0
9/10/2003 1:46:28 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
290 Views

Similar Articles

[PageSpeed] 26

Good evening Oleg

I've tried to do that, but i got one Error

<---Error

An unhandled exception of type 'System.InvalidOperationException' occurred
in system.xml.dll

Additional information: Cannot set a value on node type: Element.

--->End Error

I've selected the first Element with Xpath


loDoc is a XMLDocument

loDoc.SelectSingleNode("/LicenceControlFile/MachineName").Value =
sMachineName



Whats wrong ?

Regards from Switzerland

Peter

"Oleg Tkachenko" <oleg@NO_SPAM_PLEASEtkachenko.com> wrote in message
news:eD8UFN6dDHA.568@TK2MSFTNGP11.phx.gbl...
> Peter Treier wrote:
>
> > <?xml version="1.0" encoding="utf-16"?>
> > <LicenceControlFile>
> >   <Licence1>2AB7-FA43-B05C-4C2A-8DBD</Licence1>
> >   <MachineName />
> >   <Licence2>2AB7-FA43-B05C-4C2A-8DBD</Licence2>
> >   <MachineName />
> >   <Licence3>2AB7-FA43-B05C-4C2A-8DBD</Licence3>
> >   <MachineName />
> >  </LicenceControlFile>
> >
> > Now i need to set the Value of one of the  <MachineName /> Elements !
> > How can i do this with .NET...
>
> The simplest (but not necessarily the most effective) way is to load
document
> to XmlDocument, select appropriate MachineName element using
SelectSingleNode
> method, update it and save document back.
> -- 
> Oleg Tkachenko
> http://www.tkachenko.com/blog
> Multiconn Technologies, Israel
>


0
9/10/2003 2:28:08 PM
Peter Treier wrote:

> <?xml version="1.0" encoding="utf-16"?>
> <LicenceControlFile>
>   <Licence1>2AB7-FA43-B05C-4C2A-8DBD</Licence1>
>   <MachineName />
>   <Licence2>2AB7-FA43-B05C-4C2A-8DBD</Licence2>
>   <MachineName />
>   <Licence3>2AB7-FA43-B05C-4C2A-8DBD</Licence3>
>   <MachineName />
>  </LicenceControlFile>
> 
> Now i need to set the Value of one of the  <MachineName /> Elements !
> How can i do this with .NET...

The simplest (but not necessarily the most effective) way is to load document 
to XmlDocument, select appropriate MachineName element using SelectSingleNode 
method, update it and save document back.
-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
9/10/2003 2:59:57 PM
Peter Treier wrote:


> I've tried to do that, but i got one Error
> 
> <---Error
> 
> An unhandled exception of type 'System.InvalidOperationException' occurred
> in system.xml.dll
> 
> Additional information: Cannot set a value on node type: Element.
> 
> --->End Error
> 
> I've selected the first Element with Xpath
> 
> 
> loDoc is a XMLDocument
> 
> loDoc.SelectSingleNode("/LicenceControlFile/MachineName").Value =
> sMachineName
> 
> 
> 
> Whats wrong ?

Forgot to mention, you have to create text node. In DOM elements have no 
value. Text is stored in text nodes' value. So you have to create text node, 
set its value and append it as a child to the element.
Something like
XmlNode elem = loDoc.SelectSingleNode("/LicenceControlFile/MachineName");
XmlText textNode = loDoc.CreateTextNode(sMachineName);
elem.AppendChild(textNode);

-- 
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

0
oleg7603 (294)
9/11/2003 9:43:59 AM
Reply:

Similar Artilces:

ThisWorkbook.RefreshAll Issue/Question
I have a problem I was hoping someone might be able to help with. My environment is as follows: * OS: Windows 7 -or- Windows XP SP3 (does not seem to matter) * Excel 2007 (12.0.6514.500) SP2 MSO (12.0.6425.1000) * Microsoft Visual Basic 6.5.1040 (installed from the Office CD with Excel 2007) * WSS 3.0 SP1 (on a remote server) I am using an macro-enabled Excel workbook (xlsm) that contains connections to a dozen SharePoint lists. When I call the ThisWorkBook.RefreshAll function in one of my routines, I sometimes (not always) recieve multiple error messages as follows: * ...

Charting
A couple of easy - should be, but for the life of me I can't get it figured. Excell 2000 Simple list of 10 sequential numbers witha value for each A B 101 5.5 102 6.9 103 3.5 etc etc I want a graph with 101, 102 103 etc for the X-axis and a simple connected line graph of the various points In my case the actual data in column B are calculated and will be between 0 and 10 If I just select column B and select a line graph, it uses X value of 1,2,3 - and for some reason I can't get it to use the A values as labels I can select A:B with a Line graph, I get 2 series 101...

Sort & Page Setup Question
Hopefully this is the correct forum for my question/problem. I am trying to create a songbook that includes both an Artist Name (Column A) and Song Title (Column B). What I would like to do is have the artist name column continue on the same page in a third column (Column C) and the song title column continue in a fourth column (Column D). So, as an example, Artist Names beginning with "A" run down the first colum and continue alphabetically in the third column and then start on the second page in the first column and so on. The best way I can describe the format I want is...

Video timecode question
Hello, I am a video editor and am trying to figure out how to get Excel 2000 to calculate the difference between two frames of video... Let me explain: all frames of digital video have a timecode which is expressed as the SMPTE value and is shown as hh:mm:ss:ff where ff are frames (25 frames per second in PAL, 30 frames per second in NTSC). I want to take a value such as 00:32:43:10 and subtract 52 seconds and 5 frames from that (00.00.52.05) and get Excel to show me the result. I have tried and tried and got nowhere on this, and am not sure why: now I am appealing for your help! First...

Newbie Question
Is there a way to create an Excel database to input information and then pull info into a form? We need to have 3 diferent forms that info could be pulled from a database so that the forms don't need to be handwritten or typed each time. I'm willing to do the research needed to do this if it is possible. Info would change, and not all fields would be pulled into each form. I hope this makes some sense. Thanks. Set up your database in columnar format so's you can use VLOOKUP formulas in your 3 forms to pull data based upon criteria. Good place to start for info is ...

OWA Question #3
Is there a way to have OWA ask for the mailbox you are trying to sign into? Like exchange 5.5? "Mark" <anonymous@discussions.microsoft.com> wrote: >Is there a way to have OWA ask for the mailbox you are >trying to sign into? Like exchange 5.5? Use the URL: http://<server>/Exchange/<mbx> <server> is the server name (can be a F/E server) <mbx> is the <local-part> of a SMTP address assigned to the mailbox -- Rich Matheisen MCSE+I, Exchange MVP MS Exchange FAQ at http://www.swinc.com/resource/exch_faq.htm ...

Worksheet_Change() and Range question 12-12-09
If someone highlights a block of cells and presses "delete" to delete all the data in those cells, Excel will pass all those changed cell addresses to "Worksheet_Change()" into the "Target" variable. My question is, how do I enumerate through all the cells contained in the "Target" range variable?? The "Target" variable seems to contain a single string of all the cell addresses that were changed, and I'm looking for an easy way to extract each cell address from the "Target" variable. I initially thought I could use t...

Printing Question????
I want to print out 2 pages per sheet in lanscape at A5 size. It is a big long list which I want to print but I want to save on paper and ink. Thanks in advance. Reece. Please tell us a little more. You want to print 1 worksheet on 2 pages of paper? What is the problem? -- Bernard Liengme www.stfx.ca/people/bliengme remove CAPS in email address "Reece" <rnet@f2s.com> wrote in message news:1101120445.rQhp7aKV22sviU9XCgGvkw@teranews... >I want to print out 2 pages per sheet in lanscape at A5 size. It is a big > long list which I want to print but I want to save o...

question about ICON of frame display?
i use a customized icon for my app. and everthing is ok except that display in caption bar. i mean that it can be displayed in task bar, but for caption bar, it always is substituted by default app icon. so, how to display the customized icon in caption bar just like display in task bar. ps: there are 3 formats of size images in the customized icon, they are 16*16, 32*32, 48*48. and they are all true color. -- Frank F.Han +-----------------------------------------+ | winsays@:-)hotmail:-).com | +-----------------------------------------+ Did you create both a 32x32 and 16...

WinInet Questions
I have a question about using the WinInet Library. I am trying to use it to download some data from the web, unfortunatly to get to this information it requires a username and password. So how should I go about issuing my userid and password? The login style looks to be the same as yahoo mail login. So how do I issue it? ...

After Update Questions
I have the following code in a form. I have two questions: 1) The bulk of the code is to populate an unbound field with the day of the week. This piece of code works just find as long as the values are entered from the keyboard. When the Default Value is set (to the current date), this code does not produce any results--the day of week field is blank. If I type over the default with any date, the code works again. 2) The last line is intended to reset the Default Value to the last entered value to simplify data entry. I have used similar code in other applications with no probl...

Questions regarding Data center operation
Hi, I have over 8 years of IT experience but very new to the Data Center space and have 4 questions. If someone can answer, I would really appreciate! You can consider these questions more of a brainstorming ideas. 1. If a facilities capacity is re-classified as 5 MW lower than it was previously, what needs to happen here? 2. We need to expand Network capacity at a facility by 2 times but for only 20% more money, how can we do it? 3. Where to start if you are responsible for tech refresh in existing facility? 4. During tech refresh planning you find out about a delay in delivery...

Excel 2003 Worksheet formatting questions
I have created a simple income daysheet for my medical practice. The idea is for all money collected and received in a day to be inputted in that day's day sheet along with the source of the money, why it was received and if there is a check or statement number associated with the payemnt for it to be recorded. My questions are: 1. Column A is for date - I want to automatically enter the current date in each cell in column A. So when a new payment is being entered the current date is automatically entered for the payment clerk. I can get the date in 1 cell using the date functio...

Outbox Question #2
Hi I run Outlook 2003 When I am in another part of the Office Suite I sometimes send the file I am working on to someone else. For example, I am in Excel and decide to select the "Send To Mail Recipient" as an attachment. This works fine. However it only goes as far as my Outbox and sits there until I actually go into the Outbox and select Send/Recieve from the menu. Even when I have Outlook opened when I send the Excel file it still does not automatically go until I pick Send/Recive. Is there a way that the Outbox will send without me having to go in there and force it to ...

Outlook 2003 Headers Question
After a day with my filters I finally figured out how to make one of my three accounts challenge response but now I have a problem I cannot seem to resolve. I want to be able to configure Outlook 2003 to show me the full email headers as it downloads. Can this be done or do I have to take the Options path each time?\ Thank you kindly -- Peter Peter Clifford <newzgroups@despammed.com> wrote: > I want to be able to configure Outlook 2003 to show > me the full email headers as it downloads. Can this be done or do I > have to take the Options path each time?\ The latter. Ou...

Tax Collected Question
Is there a report to run that will show the tax that has been paid by the customer and not on the tax that was collected via a tender? Or is there a report to run that shows invoices have been paid by check, credit card, or cash that leaves out those tendered to account? We would like to be able to pay taxes on what has been paid to us and not what we are waiting on for payment. hi send me your email I will forward you some interesting reports for your below issue. "bevans22" wrote: > Is there a report to run that will show the tax that has been paid by the > custome...

Priv.edb Move Question
I've read MSKB 270693 about moving the private and public EDB and STM files on my Exchange 2003 SP2 server. I'm worried, however, about available disk space. I currently have on ServerA: C: 12 GB. (3.4 GB Free) E: 44 GB. (27 GB Free) W: 2 GB. (130 MB Free) Exchange is current installed on C. My goal is to get all the log files and edb files onto W. (The system is already a RAID5, the letters refer to logical partitions.) The Priv1.edb on E is 9.5 GB (3.4 GB stm) and the Pub1.edb is 61 MB (2 MB stm). Due to other constraints that I cannot change, I need to eliminate the E d...

11 x 17 question
I am trying to create an 11 x 17 page and print it on two sheets of 8 1/2 x 11. However I can only seem to be able to do it on 4 sheets. Why is that and is there a way to change it to 2 sheets. Have you tried deleting the extra pages? -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "jenof7" <jenof7@discussions.microsoft.com> wrote in message news:007BE8C3-D506-4641-8DF8-C7C444A61324@microsoft.com... >I am trying to create an 11 x 17 page and print it on two sheets of 8 1/2 x > 11. However I...

Project Server 2010 Beta Questions re: SharePoint 2010 Beta and Windows client requirement
Does SharePoint 2010 Beta come with the Project Server 2010 Beta or do we need to download SharePoint 2010 Beta separately? If so, which SharePoint 2010 Beta needs to be downloaded, "Enterprise CAL Features" or "For Internet Sites Beta, Enterprise"? Am I correct in reading (in MSPROJECTEXPERTS documentation) that "Windows Vista or higher" is required for the client? Folks, we never went to Vista and just now are looking at upgrading users from XP to Windows 7 - not across the board either. If you MUST be running Windows 7 to even use PWA, that is ...

Rules question an spam killing
I keep getting spam where the message is actually embedded in an image file so that you can't use a rule to filter on keywords. Does anyone know how I could send this crap to the deleted items? The messages are being sent by many different senders - I guess some SOB found a new way to piss us off and is eithre spoofing addresses or enrolled a bunch of fools in his scheme. These messages always advertise shares. Does any one know how to filter these to the deleted items? For now I just add the sender to the blocked sender's list but they keep coming from new senders. I don't wa...

Outlook 2003 question #4
Hi ... I have 4 email accounts with outlook 2003 and they are all from the same isp provider ... My problem is when i am going to create an email to someone i can't tell which email account is sending the email to , its usually set a default ... What i mean is that when i view my email accounts they are listed as so and so default , # 1 , # 2 , # 3 , I don't know what 1 or 2 or 3 are ... Is there a way to notice which email account is which beside having numbers beside them ... I can't tell which is which ... It would be better if you could view the actual name of the ema...

ADO FIND question
I have a VB program accessing non-indexed tables (by primary key). I'm using the RECORDSET.OPEN / RECORDSET.FIND syntax, coupled with RECORDSET.MOVENEXT. I would like to be able to stop the quesry when the last record with my specified value is found. How can I do that when the field I'm using is not indexed (even though it's a key field)? Any insight would be appreciated. Thanks! ...

QUESTION ABOUT DISABLING A BUTTON ON A FORM
I have 2 checkbox on a form and a button. The button is disabled when the form is loaded and enabled when either of the checkboxes is checked. What I want to do is set things up such that when the checkboxes are both unchecked, the button is disabled. I tried the On Current event of the form, see below, but that didn't work. Any ideas? Thanks Private Sub Form_Current() If Me.chkFilterBy.Value = False And Me.chkTimeRange.Value = False Then Me.cmdFilter.Enabled = True Else Me.cmdFilter.Enabled = False End If End Sub Private Sub Form_Load() M...

Mail merge question
This is a multi-part message in MIME format. ------=_NextPart_000_0009_01C81A17.BAB51A20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I've been reading about mail merge, setting up postcards, etc. I remember doing this when I did the tutorials in Publisher 2000, but = still not sure about it (I've never had to actually use it, but have a = few ideas about using it for postcards for people I have made flyers = for) What is the best program to make the mailing list in? I now have 2007 = and have Word (I know enough about to...

Month view question please
Outlook 2003 Can I get it to show start times in the month view? Thanks... Bob "Bob Newman" <bobnewman@cox.net> wrote in message news:PVPHi.100261$GO6.84541@newsfe21.lga... > Outlook 2003 > > Can I get Outlook 2003 it to show start times of appointments in the month view? > > Thanks... Bob > > "Bob Newman" <bobnewman@cox.net> wrote in message news:0P8Ii.46346$hP1.8443@newsfe13.lga... > > "Bob Newman" <bobnewman@cox.net> wrote in message > news:PVPHi.100261$GO6.84541@newsfe21.lga... >> Outlook 2003 >...