Page 1 of 1
SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 5:31 pm
by lazarusoft
Code: Select all
;
; BUG Purebasic 5.30 Beta 7 x 1 Brazil
;
OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(1, a, "Line "+Str(a))
Next
;
WaitWindowEvent()
Define.s tx = GetGadgetText(1)
Delay(100)
Define xml = CreateXML(#PB_Any,#PB_UTF8)
;SetXMLEncoding(xml,#PB_UTF8)
Define mainNode = CreateXMLNode(RootXMLNode(xml),"Zoo")
Define item = CreateXMLNode(mainNode,"Animal")
SetXMLAttribute(item, "id", tx);Bug
;SetXMLNodeText(item, tx);OK
FormatXML(xml,#PB_XML_CutNewline)
Define xmlsize = ExportXMLSize(xml)
Define *Memx=AllocateMemory(xmlsize)
ExportXML(xml, *Memx, xmlsize);
;Debug GetXMLEncoding(xml)
Define nxml$=PeekS(*Memx, xmlsize) ; in 5.22 OK
Debug nxml$
Debug ComposeXML(xml);Change utf8 to ascii
End
Re: SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 5:50 pm
by STARGÅTE
Can you explain the bug? I don't understand the code and the output.
㼼浸敶獲潩㵮ㄢ〮•湥潣楤杮∽呕ⵆ∸㸿娼潯㰾湁浩污椠㵤䰢湩☰ㄣ㬳⌦〱䰻湩☱ㄣ㬳⌦〱䰻湩☲ㄣ㬳⌦〱䰻湩3
<?xml version="1.0" encoding="UTF-16"?><Zoo><Animal id="Line 0 Line 1 Line 2 Line 3 Line 4 Line 5 "/></Zoo>
ExportXMLSize() gives the size in
bytes but PeekS() needs a length in
characters!
FormatXML() don't formats attributes:
"The formatting of the parsed XML document is stored in the 'text' and 'offset' fields of each node"
Re: SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 6:33 pm
by lazarusoft
Code: Select all
OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
EditorGadget(1, 8, 8, 306, 133)
For a = 0 To 5
AddGadgetItem(1, a, "Line "+Str(a))
Next
;
WaitWindowEvent()
;
Define.s tx = GetGadgetText(1)
;
Define xml = CreateXML(#PB_Any,#PB_UTF8)
CompilerIf #PB_Compiler_Version =530
Define mainNode = CreateXMLNode(RootXMLNode(xml),"Zoo")
Define item = CreateXMLNode(mainNode,"Animal")
CompilerElse
Define mainNode = CreateXMLNode(RootXMLNode(xml))
SetXMLNodeName(mainNode, "Zoo")
Define item = CreateXMLNode(mainNode)
SetXMLNodeName(mainNode, "Animal")
CompilerEndIf
SetXMLAttribute(item, "id", tx)
;SetXMLNodeText(item, tx)
FormatXML(xml,#PB_XML_CutNewline)
Define xmlsize = ExportXMLSize(xml)
Define *Memx=AllocateMemory(xmlsize)
ExportXML(xml, *Memx, xmlsize);
Define nxml$=PeekS(*Memx, xmlsize);
Debug nxml$
End
Debug In Purebasic 5.22
<?xml version="1.0" encoding="UTF-8"?><Animal>< id="Line 0
Line 1
Line 2
Line 3
Line 4
Line 5
"/></Animal>
Debug in Purebasic 5.30b7
<?xml version="1.0" encoding="UTF-8"?><Animal>< id="Line 0 Line 1 Line 2 Line 3
The xml version 5.30b7 of the error with a memory transfer
Re: SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 6:39 pm
by Comtois
; BUG Purebasic 5.30 Beta 7 x 1 Brazil

Re: SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 7:01 pm
by freak
This is not a bug. Newline characters are not allowed in XML attributes, so they are encoded with the appropriate character entities.
Re: SetXMLAttribute with #LFCR$
Posted: Wed Jul 09, 2014 8:31 pm
by lazarusoft
I'll switch to SetXMLNodeText,
but in PureBasic 5.22 is working well,
for this reason I thought it was a bug.
; Purebasic 5.30 Beta 7 x 1 Brazil
