# Reading XML

**URL:** <https://forums.powershell.org/t/reading-xml/8033>\
**Category:** PowerShell Help\
**Created:** [February 10, 2017, 12:55pm UTC](https://forums.powershell.org/t/reading-xml/8033 "2017-02-10T12:55:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarek-c](https://avatars.discourse-cdn.com/v4/letter/j/e56c9b/32.png) [@jarek-c](https://forums.powershell.org/u/jarek-c)\
**Post date:** [February 10, 2017, 12:55pm UTC](https://forums.powershell.org/t/reading-xml/8033/1 "2017-02-10T12:55:28Z")

</div>

I have a simple XML file with the regular “header” and one root element containing multiple child elements where some contain values describing the host and some are empty. My problem is when I save my xml into a variable  
[xml]$xml = Get-Content host.xml  
$details = $xml.host

I then try to extract the values for of the child elements like so  
$xml.host.serialNumber - this works. But when I use my $details variable it doesn’t.  
$details.serialNumber - this doesn’t.  
What am I missing?

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [February 15, 2017, 4:17am UTC](https://forums.powershell.org/t/reading-xml/8033/2 "2017-02-15T04:17:20Z")

</div>

This is strange,

Which PS Version ?  
Can you post the content of xml or any test xml content where you face this issue.  
and are you getting any error ?

Regards,  
kvprasoon

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:39pm UTC](https://forums.powershell.org/t/reading-xml/8033/3 "2024-05-16T20:39:15Z")

</div>

Closed on May 16, 2024, 8:39pm UTC


