Sunday, 15 January 2012

syntax - @ character around atomic attribute in XML File -



syntax - @ character around atomic attribute in XML File -

background

whilst looking 1 of our system's config files, found below within xml config file:

<crn:parameter name="serverlocale" @crn_serverlocale_disabled@> <crn:value xsi:type="xsd:language">en</crn:value> </crn:parameter>

@crn_serverlocale_disabled@ looks invalid me; i've never seen in xml before. assumption invalid xml, used pre-processor used scheme prior xml parsing (or perhaps specialised xml parser geared handle this).

i discovered issue i'd knocked script query values on config files on various servers (saves logging each one), reported issue. supports assumption above invalid xml, perhaps it's niche feature not implemented ms?

$servers | %{ $val = select-xml -path ("\\{0}\share\folder\config.xml" -f $_) -xpath "//*[local-name()='parameter'][@name='caf_enabled']/*[local-name='value']/text()" write-host ("server: '{0}' :: value: '{1}'" -f $_,$val) }

nb: scheme ibm's cognos reporting tool.

questions

is valid xml: <crn:parameter name="serverlocale" @crn_serverlocale_disabled@>? is there easy way allow powershell read xml; perhaps using different parser, or stripping invalid data?

update

i created next powershell strip invalid pieces prior querying...

$xml = [xml]((get-content ("\\server\share\folder\config.xml")) -replace "@\s*@", "") $val = select-xml -xpath "//*[local-name()='parameter'][@name='caf_enabled']/*[local-name='value']/text()" -xml $xml write-host ("server: '{0}' :: value: '{1}'" -f $_,$val)

however gives next error:

cannot convert value "system.object[]" type "system.xml.xmldocument". error: "unexpected xml declaration. xml declaration must first node in document, , no white space characters allowed appear before it.

nb: xml declaration has no whitespace, comments, or other characters prior (before or after running replace)

no, that's not valid xml. no, there's no easy way powershell read since it's not valid xml.

note "not valid xml" same thing "not xml". in other words, it's garbage.

most likely, that's sort of substitution token pre-processor software meant replace valid attribute.

xml syntax cognos cognos-8

No comments:

Post a Comment