Title: `Write-Host` renders an `[xml]` or `[XmlElement]` instance as an empty line. · Issue #24508 · PowerShell/PowerShell · GitHub
Open Graph Title: `Write-Host` renders an `[xml]` or `[XmlElement]` instance as an empty line. · Issue #24508 · PowerShell/PowerShell
X Title: `Write-Host` renders an `[xml]` or `[XmlElement]` instance as an empty line. · Issue #24508 · PowerShell/PowerShell
Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerShell 5.1 and PowerShell. Steps to reprodu...
Open Graph Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
X Description: Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/24508
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`Write-Host` renders an `[xml]` or `[XmlElement]` instance as an empty line.","articleBody":"### Prerequisites\r\n\r\n- [X] Write a descriptive title.\r\n- [X] Make sure you are able to repro it on the [latest released version](https://github.com/PowerShell/PowerShell/releases)\r\n- [X] Search the existing issues.\r\n- [X] Refer to the [FAQ](https://github.com/PowerShell/PowerShell/blob/master/docs/FAQ.md).\r\n- [X] Refer to [Differences between Windows PowerShell 5.1 and PowerShell](https://learn.microsoft.com/powershell/scripting/whats-new/differences-from-windows-powershell).\r\n\r\n### Steps to reproduce\r\n\r\n\r\n```powershell\r\nWrite-Host ([xml] '\u003cOhElement\u003eWhere art thou?\u003c/OhElement\u003e').DocumentElement\r\n```\r\n\r\nNote: The problem _may_ come down to the base class, `System.Xml.XmlNode`, implementing `IEnumerable`, and `Write-Host` not only enumerating the given instance itself, but doing so recursively, down to the leaf elements that by definition have nothing to enumerate. As argued below, no enumeration should take place at all.\r\n\r\n\r\n### Expected behavior\r\n\r\n```console\r\nOhElement\r\n```\r\n\r\ni.e., the name of the element, as if you had applied `.ToString()` to the instance.\r\n\r\nNote that even though such instances technically implement `IEnumerable`, for consistency with pipeline enumeration behavior I expect them _not_ to be enumerated.\r\n\r\nI suspect that the bug is related to the fact that they _are_ enumerated.\r\n\r\n\r\n### Actual behavior\r\n\r\n```console\r\n(An empty line prints.)\r\n```\r\n\r\n\r\n### Error details\r\n\r\n_No response_\r\n\r\n### Environment data\r\n\r\n```powershell\r\nPowerShell 7.5.0-preview.5 (problem dates back to Windows PowerShell)\r\n```\r\n\r\n\r\n### Visuals\r\n\r\n_No response_","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2024-10-30T20:07:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/24508/PowerShell/issues/24508"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:31cc1c4b-dcc2-8a9d-6658-d36a0eaf9984 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AABE:30460E:4D307C2:640192A:6A5D600B |
| html-safe-nonce | e5d29a0d196805b51251ba80e08f18a76c7729b2469ef3d76a0d723611f0e7b8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUJFOjMwNDYwRTo0RDMwN0MyOjY0MDE5MkE6NkE1RDYwMEIiLCJ2aXNpdG9yX2lkIjoiNTM5MzI1NTA1MzE1NDY3MjY1MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | faea062afb753a80ecd29bf54ea9742366677fc55837620b2bf600ed303759bb |
| hovercard-subject-tag | issue:2625226918 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/24508/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b70432f97c4d6aa94da104760c326afcfa0ecd962207a895aa1eab1a373ec012/PowerShell/PowerShell/issues/24508 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b70432f97c4d6aa94da104760c326afcfa0ecd962207a895aa1eab1a373ec012/PowerShell/PowerShell/issues/24508 |
| og:image:alt | Prerequisites Write a descriptive title. Make sure you are able to repro it on the latest released version Search the existing issues. Refer to the FAQ. Refer to Differences between Windows PowerSh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width