Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
WebView2 ExecuteScriptAsync with XML input

I want to run a C# function using ExecuteScriptAsync() with XML text as input.

Something like that:

var xml = "<?xml version=\"1.0\" encoding=\"UTF - 16\" standalone=\"no\" ?><values>42</values>";
webView2Control.CoreWebView2.Navigate("file:///C:/Users/erezf/AppData/Local/Temp/index.html");
var input = "func(" + xml + ")";
await webView2Control.CoreWebView2.ExecuteScriptAsync(input);

The HTML file includes the function func:

<script id="test" type="text/javascript">
    function func(xml) { alert(xml); }
</script>

This code doesn't work, why?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Your XML string being passed to the Javascript function is missing single or double quotes. If you look at the input variable in the debugger, it will look like:

func(<?xml version="1.0" encoding="UTF - 16" standalone="no" ?><values>42</values>)

Simply add single quotes like this:

var xml = "'<?xml version=\"1.0\" encoding=\"UTF - 16\" standalone=\"no\" ?><values>42</values>'";
about 4 years ago · Santiago Trujillo Relatório

0

In my case the solution was:

1. add ' ' in the " ".
2. replace the "\n" with "\\n".
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda