0

Here is my html file:

<!DOCTYPE html>
<html>
<head>

</head>
<body>
    <script id="ScriptId" src=""></script>
</body>
</html>

I want to replace empty src by script.js.

I tried with XmlPoke, but my XPath query doesn't work I think or maybe I can't do this way:

<XmlPoke XmlInputPath="test.html"
          Query="/html/body/script[id='ScriptId']/src"
          Value="script.js"/>

Thanks in advance to help me to update this src value.

Alphapage
  • 901
  • 1
  • 6
  • 29

1 Answers1

1

Attributes in XPath are prefixed with @.

/html/body/script[@id='ScriptId']/@src

You probably shouldn't be using something designed for XML with HTML as two are not the same, at best, if HTML is well-formed, it'll strip out non-XML stuff like DOCTYPE, at worst it'll blow up.

Ilya Kozhevnikov
  • 10,242
  • 4
  • 40
  • 70