OT: Copilot makes a slight mistake

Started by spl, March 17, 2025, 11:24:23 AM

Previous topic - Next topic

spl

Having enjoyed the thread for fun with xml, reminded me of the old days in WB when a topic was broached by multiple participants all until the code was adequate. Maybe now, AI is the answer. So I asked copilot "Give me a Winbatch script to parse xml nodes"

AddExtender("WWInt51i.DLL", 0, 0) ; Load the XML extender

; Define the XML content or file path
xmlContent = `"<root>
                  <node1>Keep Me</node1>
                  <node2>Remove Me</node2>
                  <node3>Keep Me Too</node3>
               </root>"`

; Load the XML into the extender
xmlDoc = XMLLoadString(xmlContent)

; Find and remove the nodes you don't want
while XMLFindElement(xmlDoc, "node2")
    XMLRemoveElement(xmlDoc, "node2")
endwhile

; Save or output the modified XML
newXmlContent = XMLGetString(xmlDoc)
Message("Modified XML", newXmlContent)

; Clean up
XMLRelease(xmlDoc)

?????????????????
Stan - formerly stanl [ex-Pundit]

td

I guess you would need to perform some model training...
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Quote from: td on March 17, 2025, 01:34:56 PMI guess you would need to perform some model training...

Nah! Just need to find where the Extender is hiding [where is a good imogi when you need one]
Stan - formerly stanl [ex-Pundit]

td

Good luck with that. But there is always the alternative of you writing one for all of us.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Quote from: td on March 18, 2025, 09:03:42 AMGood luck with that. But there is always the alternative of you writing one for all of us.

Hey AI, can you write me a 32/64 bit Extender for manipulating XML in Winbatch?
Stan - formerly stanl [ex-Pundit]

td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

Quote from: spl on March 18, 2025, 11:01:39 AMHey AI, can you write me a 32/64 bit Extender for manipulating XML in Winbatch?


I already did ;-)

td

There you go. Problem solved and, at least I hope, no AI needed.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

guuzendesu

I don't have any idea when it comes to XML, but how did Grok do?

; WinBatch script to parse XML nodes

; Define the XML file path
cXML = "example.xml"

; Check if the file exists
If ! FileExist(cXML) Then
    Message("Error", "XML file not found: " : cXML)
    Exit
EndIf

; Create the DOM object
oDOM = ObjectOpen("Msxml2.DOMDocument.4.0")
oDOM.async = @false
oDOM.Load(cXML)

; Check for parse errors
If oDOM.parseError.errorCode != 0 Then
    Message("Error", "Failed to load XML: " : oDOM.parseError.reason)
    ObjectClose(oDOM)
    Exit
EndIf

; Select the nodes, for example, all <node> under <root>
oNodes = oDOM.SelectNodes("/root/node")

; Loop through the nodes and display their text
For i = 0 To (oNodes.length - 1)
    elem = oNodes.Item(i)
    Message("Node value", elem.Text)
Next

; Close the DOM object
ObjectClose(oDOM)
Exit

SMF spam blocked by CleanTalk