PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → Using xmlDocument as parameter causes RUNTIME ERROR
Using xmlDocument as parameter causes RUNTIME ERROR
Iniciado por vvido, 28,mar. 2018 10:27 - 2 respuestas
Miembro registrado
94 mensajes
Publicado el 28,marzo 2018 - 10:27
I am trying to do some work with xmlDocument. When I pass the name of xmlDocument as string the code works, but when I pass the name of xmlDocument as variable, the code crashes with runtime error.

I am working with the same XML source file in both cases.

To demonstrate the problem I have isolated the simplest possible example.
Test 1 finds the element as expected. Test 2 crashes in XMLFind.

// TEST 1 -- this works -- xmlDocument as a string
myDoc is string = fLoadText( sFName)
XMLDocument("XMLMain", myDoc)
r = XMLFind ("XMLMain", "TestNumber", XMLElement)
IF True = r
Info ("test1 - FOUND ")
ELSE
Error ("test1 - NOT FOUND " + ErrorInfo())
END

// TEST 2 -- this DOES NOT work -- xmlDocument as variable
myXml is xmlDocument
myXml = XMLOpen(sFName,fromFile) //the document is correctly loaded (the structure checked in debugger)
r = XMLFind (myXml, "TestNumber", XMLElement) // RUNTIME ERROR: XMLFind function called. Error caused by 1 parameter. An element of 'xmlDocument' type cannot be converted to the 'UNICODE string' type.
IF True = r
Info ("test2 - FOUND ")
ELSE
Error ("test2 - NOT FOUND " + ErrorInfo())
END


What am I missing ?
Publicado el 03,abril 2018 - 17:24
 = XMLDocument( [,  [, 


This procedure doesn't accept a xmlDocument variable but needs the name of a XML Document that was created by using the procedure XMLDocument()
Miembro registrado
94 mensajes
Publicado el 04,abril 2018 - 08:53
Thanks for your reply.
I have checked the help again and realized that this was no possible.

Unfortunately the library is not designed to allow parameterization. This will cause lots of code repetition.