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:\\WINDOWS\\Panther\\Sysprep.xml");
// Create an XmlNamespaceManager to resolve the default namespace.
XmlNamespaceManager nsmgr = new
XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("bk", "urn:schemas-microsoft-com:unattend");
// Select and display all book titles.
XmlNodeList nodeList;
XmlElement root = doc.DocumentElement;
nodeList =
root.SelectNodes("/bk:unattend/bk:settings/bk:component", nsmgr);
Is it possible to select the computername element directly to edit or get to
the "settings pass="specialize" node?
nodeList =
root.SelectNodes("/bk:unattend/bk:settings/bk:component/bk:component
name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86"
publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/bk:settings
pass="specialize"/bk:ComputerName", nsmgr);
sysprep.xml
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup"
processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>net user administrator
/active:yes</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE>
<NetworkLocation>Work</NetworkLocation>
<HideEULAPage>true</HideEULAPage>
<SkipMachineOOBE>false</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<ProtectYourPC>1</ProtectYourPC>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>aQBzAHQAbABhAGIAMgAxAEEAZABtAGkAbgBpAHMAdAB yAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
<VisualEffects>
<FontSmoothing>ClearType</FontSmoothing>
</VisualEffects>
</component>
</settings>
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup"
processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserData>
<AcceptEula>true</AcceptEula>
<FullName>iststudent</FullName>
<Organization>Penn State</Organization>
</UserData>
<EnableFirewall>true</EnableFirewall>
<EnableNetwork>true</EnableNetwork>
<Restart>Restart</Restart>
<UseConfigurationSet>true</UseConfigurationSet>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-UnattendedJoin"
processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Identification>
<Credentials>
<Domain>testnet.com</Domain>
<PasswordaQBzAHQAbABhAGIAMgAxAEEAZABtAGkAbgBpAHMAd AByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Password>
<Username>iststudent</Username>
</Credentials>
<JoinDomain>testnet.com</JoinDomain>
<UnsecureJoin></UnsecureJoin>
</Identification>
</component>
<component name="Microsoft-Windows-Shell-Setup"
processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<RegisteredOrganization>Penn State</RegisteredOrganization>
<RegisteredOwner>iststudent</RegisteredOwner>
<TimeZone>Eastern Standard Time</TimeZone>
<ComputerName>Workstation_001</ComputerName>
</component>
</settings>
<settings pass="generalize">
<component name="Microsoft-Windows-PnpSysprep"
processorArchitecture="x86" publicKeyToken="31bf3856ad364e35"
language="neutral" versionScope="nonSxS"
xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
</component>
</settings>
<cpi:offlineImage cpi:source="wim://ms001/distribition$/vista.wim#vista"
xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>