IXmlFile
Use this interface to edit an XML file and to provide access to more specific features.
Declaration
IXmlFile : IDirectoryMember
Properties
IDirectoryMember properties:
- String Name - Sets or gets the XML name.
- IFolder Directory - Sets or gets the directory in which the XML is located.
- String FullPath - Gets the path of the Advanced Installer project.
- String Type - Gets the type of the XML as a string.
IXmlFileSettings FileSettings - Gets IXmlFileSettings interface for this object that allows editing an XML file specific flags and properties.
IXmlFileSettings FileSettings - Gets IXmlFileInstall interface for this object that allows editing an XML file specific flags and properties for install time.
IXmlFileSettings FileSettings - Gets IXmlRootElement that allows editing the root an XML element of this file, to add new elements, and to navigate all the file elements.
Methods
IDirectoryMember methods:
- DeleteFile() - This method deletes the XML from the project. The object on which this method is called is no longer available for editing.
$advinst = new-object -com AdvancedInstaller $proj = $advinst.LoadProject("D:\my_app_source_folder\setup\my_app.aip") $filename = "my file.xml" $configFile = $proj.XmlFilesComponent.Files | where {$_.Name == "my_app.exe.config"}[0] if($configFile -eq $null) { $file = $proj.XmlFilesComponent.ImportFileS("APPDIR\my_app_folder", "D:\my_app_source_folder\bin\Release\my_app.exe.config") # add under RootElement all type of attributes $file.RootElement.Text = "text for root element" $file.RootElement.CreateAttributeIfNotExist("AttributeIfNotExist", "value AttributeIfNotExist") $file.RootElement.CreateIdentifierAttribute("IdentifierAttribute", "value IdentifierAttribute") $file.RootElement.CreateOrUpdateAttribute("AttributeCreateorupdate", "Value CreateorUpdate") $file.RootElement.NewAttributeRemoval("AttributeRemoval") # add children elements $file.RootElement.CreateElement("newElement") $file.RootElement.CreateElementComment("comment1","comment for new element") $file.RootElement.CreateElementRemovalAllMatching("removalAllMatching") $file.RootElement.CreateElementRemovalFirstMatching("removalFirstMatching") $file.RootElement.CreateElementSibling("NewSibling") $file.Rootelement.CreateElementUpdateAllMatching("NewElementUpdateALLMatching") $file.RootElement.CreateElementUpdateFirstMatching("NewElementUpdateFirstMatching") # add attributes to all elements -> the same attributes Foreach ($element in $file.RootElement.ChildElements) { $element.Text = "text for $($element.Name)" $element.CreateAttributeIfNotExist("AttributeIfNotExist", "value AttributeIfNotExist") $element.CreateIdentifierAttribute("IdentifierAttribute", "value IdentifierAttribute") $element.CreateOrUpdateAttribute("AttributeCreateorupdate", "Value CreateorUpdate") $element.NewAttributeRemoval("AttributeRemoval") } } # save the project $proj.Save()
Topics
- IXmlFileInstall
XML File Install interface - IXmlFileSettings
XML File Settings interface - IXmlFilesComponent
XML Files Component interface