1

I have PS script that connects to a XML file. However i get this error duo to specific a line in my XML file:

Error message: Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "'&' is an unexpected token. The expected token is ';'Line 22, position 99."

This is line 22:

<Option Name="Action" Value="https://website.com/&sys_id=a3f50914db194450165992b8db96192d" />

I've edited the website link as i cannot share this.

The last part of the value is what triggers the error starting at "&"

The error appears to be at "&" which is pos 99 in line 22. I tried to remove that and run it again. Then the error appears at "_" removing that it happens for "=". Seems like it doesn't like these special characters.

The idea is to have a button that takes you to a specific site. If i just had https://website.com then it would work but i will need it to go deeper than just to the basic frontpage.

I reckon it must be something in the PS script that needs to be modified but haven't been able to figure out what.

Any suggestions?

1
  • 2
    Looks like someone forgot to properly escape their data before serializing it :) correct escape sequence for & in a string would be &amp; Commented Nov 25, 2019 at 14:54

1 Answer 1

3

You will need to escape special characters. Here is a reference: https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/how-to-use-special-characters-in-xaml

Try this instead:

<Option Name="Action" Value="https://website.com/&amp;sys_id=a3f50914db194450165992b8db96192d" />
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot! My script is still not working but it doesn't get the unexpected token error anymore so at least in the right direction :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.