PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD20] XML nodes with same name
[WD20] XML nodes with same name
Iniciado por guest, 09,jun. 2015 20:21 - 3 respuestas
Publicado el 09,junio 2015 - 20:21
I know I can create XML with duplicate named nodes this way:

sXML is string = 22
XMLDocument("Doc",sXML)
XMLParent("Doc")
XMLAddChild("Doc", "id", 1)
XMLAddChild("Doc", "id", 5)
XMLAddChild("Doc", "id", 9)

Can I do it with an xmlDocument variable? This way only takes in to account the last id:

XMLDoc is xmlDocument
XMLDoc = XMLOpen(sXML)
XMLDoc.xml.id = 1
XMLDoc.xml.id = 5
XMLDoc.xml.id = 9
Publicado el 09,junio 2015 - 20:50
Curtis

The tag value has to be in quotes - XML is text based. sXML is string = 22 XMLDocument("Doc",sXML) XMLParent("Doc") XMLAddChild("Doc", "id", "1") XMLAddChild("Doc", "id", "5") XMLAddChild("Doc", "id", "9")
Publicado el 09,junio 2015 - 21:28
Oops. Good catch. They are in my code, forgot to add the quotes when typing out my question.
Publicado el 10,junio 2015 - 10:07
Curtis

I see, easily done:)
Back to the original question....

Yes you can do this with the XMLDocument variable.
What you need to do is declare which node you are updating. XMLDoc is xmlDocument XMLDoc = XMLOpen(sXML) XMLDoc.id[1] = "1" XMLDoc.id [2] = "5" XMLDoc.id [3] = "9"
The nodes do, of course, need to exist in the source document.

Check out the 'Example for using the XML Types' in the Help - quite a decent explanation.