XML and ?xml version How to

Just starting out? Need help? Post your questions and find answers here.
loulou2522
Posts: 51
Joined: Wed Mar 18, 2015 5:52 am

XML and ?xml version How to

Post by loulou2522 »

How to put tha't instruct on the xml file in purebasic it is automaticly
<?xml version="1.0" encoding="UTF-8"?>
Thanks
P.S I use ExportXml and not composeXML
Last edited by loulou2522 on Mon Oct 04, 2021 5:34 am, edited 1 time in total.
User avatar
Paul
Posts: 195
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: XML and ?xml version

Post by Paul »

Just add it yourself?

Code: Select all

  xml = CreateXML(#PB_Any) 
  mainNode = CreateXMLNode(RootXMLNode(xml), "Zoo") 
  
  ; Create first xml node (in main node)
  item = CreateXMLNode(mainNode, "Animal") 
  SetXMLAttribute(item, "id", "1") 
  SetXMLNodeText(item, "Elephant") 
  
  ; Create second xml node (in main node)
  item = CreateXMLNode(mainNode, "Animal") 
  SetXMLAttribute(item, "id", "2") 
  SetXMLNodeText(item, "Tiger") 
  
  ; Display the xml
  result$=~"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+ComposeXML(xml)
  Debug result$
Of course if you are using ExportXML() then this won't help ;(
I thought maybe SetXMLEncoding() might add this info since the docs make me think it should do something but when I try and use this command the browser gives an error saying "spider_SetXMLEncoding" is not defined, so no idea.
Post Reply