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>