我正在尝试创建一个包含来自其他来源的数据的XML文件。但是,目前 XML 读取器在处理布尔值时遇到问题。 有没有办法解决这个问题?
我看了一下,找不到写元素博林的命令:S
$enc = New-Object System.Text.UTF8Encoding( $false )
# get an XMLTextWriter to create the XML
$XmlWriter = New-Object System.XMl.XmlTextWriter($Path,$enc)
# write the header
$xmlWriter.WriteStartDocument()
$xmlWriter.WriteStartElement('InstanceTypes xsi:schemaLocation="http://www.citrix.com/2013/xd/AWSInstanceTypes InstanceTypes.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.citrix.com/2013/xd/AWSInstanceTypes"')
foreach($i in $testy){
$XmlWriter.WriteStartElement('InstanceType')
$xmlWriter.WriteElementString('Name',$i)
$xmlWriter.WriteElementString('MemoryMiB',3888)
$xmlWriter.WriteElementString('EC2ComputeUnits',2)
$xmlWriter.WriteElementString('VirtualCores',2)
$xmlWriter.WriteElementString('InstanceStorageGB',120)
$xmlWriter.WriteElementString('IOPerformance',2)
#####BOOLEAN Value need for the EBS Optimised Available
$xmlWriter.WriteElementString('EBSOptimisedAvailable',$true)
$xmlWriter.WriteElementString('APIName',$i)
$xmlWriter.WriteElementString('NetworkPerformance','Normal')
$xmlWriter.WriteEndElement()
}
$xmlWriter.WriteEndDocument()
$xmlWriter.Flush()
$xmlWriter.Close()
XSD 杂项数据类型 (w3schools.com( 说:
布尔数据类型
布尔数据类型用于指定 true 或 false 值。
以下是架构中布尔声明的示例:
<xs:attribute name="disabled" type="xs:boolean"/>
文档中的元素可能如下所示:
<prize disabled="true">999</prize>
注意:布尔值的合法值为真、假、1(表示 true(和 0(表示 false(。