Hello,
A long time ago I got a class named XMLParser from someone. Unfortunately I have not documented the source.
With this class I can easily build, store and read XML files. I have the source code for this class (in VO).
In this class much of the type PTR is used and I also see a lot of casts. Several functions now expect PSZ in Vulcan (and X #) and that is why I think the code needs to be rewritten properly.
Does anyone know if an XMLParser class is available somewhere (or maybe an assembly exists) that can be used to build, store and read XML files?
Thank is advance for your answer.
Eric
XMLParser
XMLParser
Hi Eric,
you can use the XML parser classes in the .NET Framework: XmlNode and XmlDocument in the System.XML namespace. I would not use VO classes if possible (I have done the inverse thing: I'm using the .NET classes in my VO application through a COM DLL).
https://docs.microsoft.com/en-us/dotnet ... mldocument
Wolfgang
you can use the XML parser classes in the .NET Framework: XmlNode and XmlDocument in the System.XML namespace. I would not use VO classes if possible (I have done the inverse thing: I'm using the .NET classes in my VO application through a COM DLL).
https://docs.microsoft.com/en-us/dotnet ... mldocument
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
XMLParser
Yeah, please check the documentation about System.Xml namespace, System.Xml.XmlDocument etc. You only need to add a reference to System.Xml library to use them
https://docs.microsoft.com/en-us/dotnet ... work-4.7.1
https://docs.microsoft.com/en-us/dotnet ... work-4.7.1
Edit: I am way slower than Wolfgang
https://docs.microsoft.com/en-us/dotnet ... work-4.7.1
https://docs.microsoft.com/en-us/dotnet ... work-4.7.1
Edit: I am way slower than Wolfgang
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
- lumberjack
- Posts: 727
- Joined: Fri Sep 25, 2015 3:11 pm
- Location: South Africa
XMLParser
Hi Eric,
HTH,
Here is a reader and writer for Xml. Methods from my IniFile to convert Ini files to Xml format. Should get you going.Intexso wrote: Does anyone know if an XMLParser class is available somewhere (or maybe an assembly exists) that can be used to build, store and read XML files?
Code: Select all
METHOD ReadXml() AS VOID
LOCAL sFileXml AS STRING
LOCAL xr AS XmlReader
LOCAL settings AS XmlReaderSettings
LOCAL s, n, v AS STRING
sFileXml := SELF:sFile:Replace(Path.GetExtension(SELF:sFile), ".config")
IF !File.Exists(sFileXml)
RETURN
ENDIF
settings := XmlReaderSettings{}
settings:IgnoreWhitespace := TRUE
xr := XmlReader.Create(sFileXml, settings)
xr:MoveToContent()
IF xr:Name == "configuration"
WHILE xr:Read()
IF xr:NodeType = XmlNodeType.EndElement
LOOP
ENDIF
IF xr:Name == "section"
s := xr["name"]
ELSEIF xr:Name == "entry"
n := xr["name"]
v := xr["value"]
SELF:SetString(s, n, v)
ENDIF
ENDDO
ENDIF
xr:Close()
RETURN
METHOD FlushXml() AS VOID
LOCAL sFileXml AS STRING
LOCAL xw AS XmlTextWriter
LOCAL s, n, v AS STRING
LOCAL sSections, sItems AS STRING[]
LOCAL i, j AS INT
sFileXml := SELF:sFile:Replace(Path.GetExtension(SELF:sFile), ".config")
IF File.Exists(sFileXml)
File.Copy(sFileXml, sFileXml + ".bak", TRUE)
ENDIF
xw := XmlTextWriter{sFileXml, Encoding.UTF8}
xw:Formatting := Formatting.Indented
xw:WriteStartDocument()
xw:WriteStartElement("configuration")
sSections := SELF:GetSectionNames()
FOR i := 0 UPTO sSections:Length - 1
s := sSections[i]
xw:WriteStartElement("section")
xw:WriteAttributeString("name", s)
sItems := SELF:GetItemNames(s)
FOR j := 0 UPTO sItems:Length - 1
n := sItems[j]
v := SELF:GetString(s, n)
xw:WriteStartElement("entry")
xw:WriteAttributeString("name", n)
xw:WriteAttributeString("value", v)
xw:WriteEndElement()
NEXT
xw:WriteEndElement()
NEXT
xw:WriteEndDocument()
xw:Close()
RETURN
______________________
Johan Nel
Boshof, South Africa
Johan Nel
Boshof, South Africa