0

I am creating an xml document with many nodes and values. The node references are set in a psd1 file so in the future if the structure changes or names change, we just need to update the psd1 file and hopefully not change the code! I am importing the psd1 file into a variable and trying to reference a setting. I then need to set the values based on the specific reporting information would like to reference the psd1 file settings and this FAILS.

The following works: doc.FinData.Header.Hdrinfo.From.CpnyId.Id.StoreId.Report.Id = xml_cfg.from_id

$doc.$xml_cfg.from_path = xml_cfg.from_id ERROR: "The property 'FinData.Header.Hdrinfo.From.CpnyId.Id.StoreId.Report.Id' cannot be found on this object. Verify that the property exists and can be set."

Tesh
  • 29
  • 4
  • We cannot see what your variables `$doc` and `$xml_cfg` contain nor did you post any example of the files.. Please [edit] your question and give us a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – Theo Nov 06 '22 at 12:18
  • XML is a text file so open file with notepad and see if the tag exists in the xml. – jdweng Nov 06 '22 at 12:28
  • It sounds like you're trying to store a property _path_ in a variable; such a variable cannot be used as-is for property access. See if [this answer](https://stackoverflow.com/a/51863728/45375) helps, and, if so, we can close your question as a duplicate. – mklement0 Nov 07 '22 at 02:49
  • Please [format your post properly](https://stackoverflow.com/help/formatting). – mklement0 Nov 07 '22 at 02:49
  • Correct, I am trying to property path in a variable and then reference it against the XML DOM. The variable path does not work however if reference the path directly against the DOM, it works fine. It is nice to have but not important. Thanks. – Tesh Nov 11 '22 at 09:40

0 Answers0