Howto convert text to XML

Just starting out? Need help? Post your questions and find answers here.
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Howto convert text to XML

Post by karu »

Can anyone help, i have xml file in text format in string variable. Now if i want to parse XML with PB commands, i need to convert this text value to PB XML. How to do this?

Thanks
Karu
User avatar
STARGÅTE
Addict
Addict
Posts: 2236
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Howto convert text to XML

Post by STARGÅTE »

With ParseXML()
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: Howto convert text to XML

Post by karu »

Thanks STARGÅTE, but only ParseXML() i fuond from here: http://www.purebasic.fr/english/viewtop ... ML+#p95066
But with this solution i cant use Purebasic XML commands like 'XMLStatus(#XML)', is there other way?
User avatar
STARGÅTE
Addict
Addict
Posts: 2236
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Howto convert text to XML

Post by STARGÅTE »

:?:

PB 5.30 Beta 4:

Code: Select all

Enumeration
	#XML
EndEnumeration

Define Text.s = ReplaceString("<Node Attribute='Value'>Text</Node>", "'", #DOUBLEQUOTE$)

If ParseXML(#XML, Text)
	Debug XMLStatus(#XML)
	*Node = MainXMLNode(#XML)
	Debug GetXMLNodeName(*Node)
	Debug GetXMLAttribute(*Node, "Attribute")
	Debug GetXMLNodeText(*Node)
EndIf
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: Howto convert text to XML

Post by karu »

Ok, but in 5.2 version?
User avatar
STARGÅTE
Addict
Addict
Posts: 2236
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Howto convert text to XML

Post by STARGÅTE »

PB 5.20:

Code: Select all

Enumeration
   #XML
EndEnumeration

Define Text.s = ReplaceString("<Node Attribute='Value'>Text</Node>", "'", #DOUBLEQUOTE$)

If CatchXML(#XML, @Text, StringByteLength(Text))
   Debug XMLStatus(#XML)
   *Node = MainXMLNode(#XML)
   Debug GetXMLNodeName(*Node)
   Debug GetXMLAttribute(*Node, "Attribute")
   Debug GetXMLNodeText(*Node)
EndIf
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
karu
Enthusiast
Enthusiast
Posts: 255
Joined: Fri Jan 13, 2006 12:14 am

Re: Howto convert text to XML

Post by karu »

Thanks STARGÅTE
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Howto convert text to XML

Post by davido »

@karu Thank you for the question.
@STARGÅTE Thank you for the answer. :D
DE AA EB
Post Reply