xml Servers
--- -------
version="1.0" encoding="utf-8" Servers
XML data to a label.text property
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- mtartaglia
- Posts: 101
- Last visit: Mon Dec 19, 2022 11:45 am
Re: XML data to a label.text property
You posted the object and not the XML.
$xml.SelectNodes('//Instance/BindingHostName')| select -expand outerXML
You also need to post you XML and not the object display. We need the text in the file. Without it there is no way I can quickly guess at you issue.
This may help you understand XML and what you need to provide:
https://www.w3schools.com/xml/cd_catalog.xml
https://www.w3schools.com/xml/
$xml.SelectNodes('//Instance/BindingHostName')| select -expand outerXML
You also need to post you XML and not the object display. We need the text in the file. Without it there is no way I can quickly guess at you issue.
This may help you understand XML and what you need to provide:
https://www.w3schools.com/xml/cd_catalog.xml
https://www.w3schools.com/xml/
Re: XML data to a label.text property
Just post the node of interest and change any I formation that is proprietary.can not post the XML file as there is information in them that I can not release. I will try to figure out what could be wrong with it. thanks for trying
Re: XML data to a label.text property
Another way to exatract the issue is this:
$file.servers.server.Instances.Instance
run that at a prompt to see how many nodes exist. To get the correct node use XPath. If the name you want is an attribute then XPath will do the search:
$file.SelectSingleNode("//Instance[@BindingHostName='$BindingURL']")
With a sample of the "Instance" node I can give you the exact XPath in a second.
$file.servers.server.Instances.Instance
run that at a prompt to see how many nodes exist. To get the correct node use XPath. If the name you want is an attribute then XPath will do the search:
$file.SelectSingleNode("//Instance[@BindingHostName='$BindingURL']")
With a sample of the "Instance" node I can give you the exact XPath in a second.
- mtartaglia
- Posts: 101
- Last visit: Mon Dec 19, 2022 11:45 am
- mtartaglia
- Posts: 101
- Last visit: Mon Dec 19, 2022 11:45 am
Re: XML data to a label.text property
My apologies, the post never saved for some reason. Below is the code for the node. I hope this is what you are looking for.
<Instance>
<Name>billybob</Name>
<Version>8.26.0.0</Version>
<InstalledVersion>8.26.0.0</InstalledVersion>
<LicenseKey>111-222-333-44444</LicenseKey>
<AppPoolName>billybob</AppPoolName>
<BindingHostName>billybob.nowhere.com</BindingHostName>
<UseSSLBinding>false</UseSSLBinding>
<ShipmentServerEndPoint />
<BindingSSLCertificate>
<RequireServerNameIdentification>false</RequireServerNameIdentification>
<Issuer />
<SerialNumber />
<Storage />
<SslStatus>Synchronized</SslStatus>
</BindingSSLCertificate>
<AuthenticationMode>Forms</AuthenticationMode>
</Instance>
<Instance>
<Name>billybob</Name>
<Version>8.26.0.0</Version>
<InstalledVersion>8.26.0.0</InstalledVersion>
<LicenseKey>111-222-333-44444</LicenseKey>
<AppPoolName>billybob</AppPoolName>
<BindingHostName>billybob.nowhere.com</BindingHostName>
<UseSSLBinding>false</UseSSLBinding>
<ShipmentServerEndPoint />
<BindingSSLCertificate>
<RequireServerNameIdentification>false</RequireServerNameIdentification>
<Issuer />
<SerialNumber />
<Storage />
<SslStatus>Synchronized</SslStatus>
</BindingSSLCertificate>
<AuthenticationMode>Forms</AuthenticationMode>
</Instance>
Re: XML data to a label.text property
Great. Now I can show you.
The following finds and extract a single instance by name.
Copy and paste it at a prompt to play with the contests of the node.
Remember that XML is case sensitive.
The following finds and extract a single instance by name.
Code: Select all
[xml]$xml = @'
<Instances>
<Instance>
<Name>billybob</Name>
<Version>8.26.0.0</Version>
<InstalledVersion>8.26.0.0</InstalledVersion>
<LicenseKey>111-222-333-44444</LicenseKey>
<AppPoolName>billybob</AppPoolName>
<BindingHostName>billybob.nowhere.com</BindingHostName>
<UseSSLBinding>false</UseSSLBinding>
<ShipmentServerEndPoint />
<BindingSSLCertificate>
<RequireServerNameIdentification>false</RequireServerNameIdentification>
<Issuer />
<SerialNumber />
<Storage />
<SslStatus>Synchronized</SslStatus>
</BindingSSLCertificate>
<AuthenticationMode>Forms</AuthenticationMode>
</Instance>
<Instance>
<Name>bobbyjoe</Name>
<Version>8.26.0.0</Version>
<InstalledVersion>8.26.0.0</InstalledVersion>
<LicenseKey>111-222-333-44444</LicenseKey>
<AppPoolName>billybob</AppPoolName>
<BindingHostName>billybob.nowhere.com</BindingHostName>
<UseSSLBinding>false</UseSSLBinding>
<ShipmentServerEndPoint />
<BindingSSLCertificate>
<RequireServerNameIdentification>false</RequireServerNameIdentification>
<Issuer />
<SerialNumber />
<Storage />
<SslStatus>Synchronized</SslStatus>
</BindingSSLCertificate>
<AuthenticationMode>Forms</AuthenticationMode>
</Instance>
</Instances>
'@
$xml.SelectSingleNode("//Instance[Name='billybob']").BindingHostName
$xml.SelectSingleNode("//Instance[Name='billybob']") | Select-Object name, version, Licensekey
$node = $xml.SelectSingleNode("//Instance[Name='billybob']")
$node.BindingHostName
Remember that XML is case sensitive.
Re: XML data to a label.text property
This is how to do what you were originally trying to do.
$bindingHost = 'billybob.nowhere.com'
$xml.SelectSingleNode("//Instance[BindingHostName='$bindingHost']").Name
$bindingHost = 'billybob.nowhere.com'
$xml.SelectSingleNode("//Instance[BindingHostName='$bindingHost']").Name
Re: XML data to a label.text property
Looking at the XML your original should have worked so I suspect the XML posted does not include all important bits of the XML like namespaces. You may need to post the complete wrapper including the XML statement and the Servers/Server tags and any namespace declarations or any schema declarations.