473,796 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change value of element with known path using XML

Hi,

I need to change a value of an element in an XML file, I have been trying to
select the node to edit but can only get as far as component and have to
itterate through..

XmlDocument doc = new XmlDocument();
doc.Load("C:\\W INDOWS\\Panther \\Sysprep.xml") ;

// Create an XmlNamespaceMan ager to resolve the default namespace.
XmlNamespaceMan ager nsmgr = new
XmlNamespaceMan ager(doc.NameTa ble);
nsmgr.AddNamesp ace("bk", "urn:schema s-microsoft-com:unattend");

// Select and display all book titles.
XmlNodeList nodeList;
XmlElement root = doc.DocumentEle ment;
nodeList =
root.SelectNode s("/bk:unattend/bk:settings/bk:component", nsmgr);

Is it possible to select the computername element directly to edit or get to
the "settings pass="specializ e" node?

nodeList =
root.SelectNode s("/bk:unattend/bk:settings/bk:component/bk:component
name="Microsoft-Windows-Shell-Setup" processorArchit ecture="x86"
publicKeyToken= "31bf3856ad364e 35" language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"/bk:settings
pass="specializ e"/bk:ComputerName ", nsmgr);
sysprep.xml

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:sche mas-microsoft-com:unattend">
<settings pass="oobeSyste m">
<component name="Microsoft-Windows-Shell-Setup"
processorArchit ecture="x86" publicKeyToken= "31bf3856ad364e 35"
language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<FirstLogonComm ands>
<SynchronousCom mand wcm:action="add ">
<Order>1</Order>
<CommandLine>ne t user administrator
/active:yes</CommandLine>
</SynchronousComm and>
</FirstLogonComma nds>
<OOBE>
<NetworkLocatio n>Work</NetworkLocation >
<HideEULAPage>t rue</HideEULAPage>
<SkipMachineOOB E>false</SkipMachineOOBE >
<SkipUserOOBE>t rue</SkipUserOOBE>
<ProtectYourPC> 1</ProtectYourPC>
</OOBE>
<UserAccounts >
<AdministratorP assword>

<Value>aQBzAHQA bABhAGIAMgAxAEE AZABtAGkAbgBpAH MAdAByAGEAdABvA HIAUABhAHMAcwB3 AG8AcgBkAA==</Value>
<PlainText>fals e</PlainText>
</AdministratorPa ssword>
</UserAccounts>
<VisualEffect s>
<FontSmoothing> ClearType</FontSmoothing>
</VisualEffects>
</component>
</settings>
<settings pass="windowsPE ">
<component name="Microsoft-Windows-Setup"
processorArchit ecture="x86" publicKeyToken= "31bf3856ad364e 35"
language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<UserData>
<AcceptEula>tru e</AcceptEula>
<FullName>istst udent</FullName>
<Organization>P enn State</Organization>
</UserData>
<EnableFirewall >true</EnableFirewall>
<EnableNetwork> true</EnableNetwork>
<Restart>Restar t</Restart>
<UseConfigurati onSet>true</UseConfiguratio nSet>
</component>
</settings>
<settings pass="specializ e">
<component name="Microsoft-Windows-UnattendedJoin"
processorArchit ecture="x86" publicKeyToken= "31bf3856ad364e 35"
language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<Identification >
<Credentials>
<Domain>testnet .com</Domain>

<PasswordaQBzAH QAbABhAGIAMgAxA EEAZABtAGkAbgBp AHMAdAByAGEAdAB vAHIAUABhAHMAcw B3AG8AcgBkAA==</Password>
<Username>istst udent</Username>
</Credentials>
<JoinDomain>tes tnet.com</JoinDomain>
<UnsecureJoin ></UnsecureJoin>
</Identification>
</component>
<component name="Microsoft-Windows-Shell-Setup"
processorArchit ecture="x86" publicKeyToken= "31bf3856ad364e 35"
language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<DisableAutoDay lightTimeSet>fa lse</DisableAutoDayl ightTimeSet>
<RegisteredOrga nization>Penn State</RegisteredOrgan ization>
<RegisteredOwne r>iststudent</RegisteredOwner >
<TimeZone>Easte rn Standard Time</TimeZone>
<ComputerName>W orkstation_001</ComputerName>
</component>
</settings>
<settings pass="generaliz e">
<component name="Microsoft-Windows-PnpSysprep"
processorArchit ecture="x86" publicKeyToken= "31bf3856ad364e 35"
language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance">
<PersistAllDevi ceInstalls>true </PersistAllDevic eInstalls>
</component>
</settings>
<cpi:offlineIma ge cpi:source="wim ://ms001/distribition$/vista.wim#vista "
xmlns:cpi="urn: schemas-microsoft-com:cpi" />
</unattend>
Feb 26 '07 #1
1 2488
Post was probably a little unclear could someone tell me if its possible to
use selectnodes when node name have values, spaces etc..

this works --root.SelectNode s("/bk:unattend/bk:settings/bk:component"

this doesnt --root.SelectNode s("/bk:unattend/bk:settings/bk:component
name="Microsoft-Windows-Shell-Setup" processorArchit ecture="x86"
publicKeyToken= "31bf3856ad364e 35" language="neutr al" versionScope="n onSxS"
xmlns:wcm="http ://schemas.microso ft.com/WMIConfig/2002/State"
xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"

Thanks..
Feb 27 '07 #2

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

Similar topics

4
10930
by: Wim Roffal | last post by:
Is it possible to use javascript to change the name of a field in a form? Thanks, Wim
4
2635
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an QA tested for a new year release. I don't think that going to prove practical, but there is no harm in trying :) and some serious family commitments. But it has to be done soon so this is stage one. Mike Winter provided an extensive list of...
21
3993
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
1
1279
by: Aravind G via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Aravind G Hello all, I have a peculiar situation. Following is a small xml snippet in use
2
19326
by: Eranga | last post by:
Is there any way that we can serach for a registry key value with a known data. For example if I want to find a registry value with the known data"InternetSearch" how can I do it on C#? for any help, thanks in advance. *** Sent via Developersdex http://www.developersdex.com ***
4
6318
by: andreas.w.h.k. :-\) | last post by:
How do I change the address location in the wsdl <wsdl:port name="SearchSoap12" binding="tns:SearchSoap12"> <soap12:address location="http://searchservices/engine/search.asmx" /> </wsdl:port> Anderas
3
6808
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer> </Root> I would like to retreive "\Root\Customer\Name" out of it. Something like:
2
2579
by: Bilal | last post by:
Hello, I'm stuck on this problem for quite some time and hope somebody would be able to guide me. Basically, I need to populate a large number of "template" XML files which have all elements/attributes etc. defined but the values in these elements/attributes might be blank or place holders, as two examples below: Example - File type 1
5
13194
by: yhlove | last post by:
Hi I'm trying to change element in xml file as described below: the xml file: ---------------- <MyProg> <Path>test1</Path> </MyProg>
0
9685
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
9535
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
10244
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10201
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
10021
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
9061
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...
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
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.