Jump to content
ChrisChuah

XML viewer component

Recommended Posts

Hi 

Is there a XML Viewer component rather than using the TWebBrowser component?

Although i can use the TMemo component to load the xml but the output is not that pretty.

Please advise

 

regards

chris

Share this post


Link to post
Posted (edited)

Since you try to display an XML in a Memo control, I presume you are using considerable sized XML files and do not need things like coloring/styling. You can use a code like below to "pretty print" your XML and display it in a Memo object.

uses
  Xml.xmldom,
  Xml.XMLIntf, // Interface
  Xml.XMLDoc;  // TXMLDocument, FormatXMLData()

procedure TForm1.Button1Click(Sender: TObject);
var
  LXML: IXMLDocument;
begin
  LXML := NewXMLDocument();
  LXML.LoadFromXML('<?xml version="1.0" encoding="UTF-8"?><some_node><another_node>node value</another_node></some_node>');
  LXML.XML.Text := FormatXMLData(LXML.XML.Text);
  Memo1.Text := LXML.XML.Text;
end;

Documentation says about TMemo "Under Win 9x, there is a limit of 64k of text for this control"

Edited by ertank

Share this post


Link to post

Something like this?

image.thumb.png.8d832007445366f27eecc60b53524510.png

The above was done with a standard TTreeView using ownerdraw (and "a few" hacks).
I've attached the source but it's part of a larger framework so it will have to be tweaked a bit in order to work standalone - Minor stuff.

 

 If I were to implement this today I would definitely use Virtual TreeView instead; L oad the XML into a DOM (e.g. MSXML/IXMLDocument), populate the treeview and ownerdraw the nodes.

amResourceViewXML.pas

amResourceViewXML.dfm

amTreeView.pas

  • Like 1

Share this post


Link to post

2056432550_ScreenShot2022-08-29at9_30_12AM.thumb.png.3a05338c0845f0b6fc34463ef3e64ede.png

tried to install the SynEdit via PackageManager and it could not be installed on Delphi 11.1

Anyone encountered this problem?

 

regards

chris

 

Share this post


Link to post

No problems encountered here. Expand the tree nodes and see more details on what is going wrong. 

 

Can also take a look in C:\Users\Public\Documents\Embarcadero\Studio\22.0 for GetItInstall.log which should also have the information on what happened. 

Share this post


Link to post

hi

here is the getItInstall.log.

From GitHub, it states that SynEdit supports up to Delphi 10.4

Could this error due to not able to support 11.1?

 

regards

chris

 

====== Start ======

[2022-08-29 09:28:55] [DEBUG] GetIt: Loading EULAS...
[2022-08-29 09:29:02] [DEBUG] GetIt: Installing Library "SynEdit for VCL"...
[2022-08-29 09:29:03] [DEBUG] GetIt: Downloading Library "SynEdit for VCL"...
[2022-08-29 09:29:07] [DEBUG] GetIt: Extracting Library "SynEdit for VCL" to "C:\Users\chuahyen\Documents\Embarcadero\Studio\22.0\CatalogRepository\SynEdit-2022.03-11\". This could take a while...
[2022-08-29 09:29:08] [DEBUG] GetIt: Compiling project "SynEditDR.dproj"...
[2022-08-29 09:29:13] [DEBUG] GetIt: Problem occurred when compiling for "Win64" platform with "Release" configuration.
[2022-08-29 09:29:15] [DEBUG] GetIt: Problem occurred when compiling for "Win64" platform with "Debug" configuration.
[2022-08-29 09:29:17] [DEBUG] GetIt: Problem occurred when compiling for "Win32" platform with "Release" configuration.
[2022-08-29 09:29:18] [DEBUG] GetIt: Problem occurred when compiling for "Win32" platform with "Debug" configuration.
[2022-08-29 09:29:19] [DEBUG] GetIt: Error when executing an action of "SynEdit for VCL" catalog. The action is "CompileProject" (ID 6).
[2022-08-29 09:29:19] [DEBUG] GetIt: A problem occurred during the process.
[2022-08-29 09:29:26] [DEBUG] GetIt: Cancelling process...
[2022-08-29 09:29:39] [DEBUG] GetIt: Loading EULAS...
[2022-08-29 09:29:41] [DEBUG] GetIt: Installing Library "SynEdit for VCL"...
[2022-08-29 09:29:41] [DEBUG] GetIt: Downloading Library "SynEdit for VCL"...
[2022-08-29 09:29:42] [DEBUG] GetIt: Extracting Library "SynEdit for VCL" to "C:\Users\chuahyen\Documents\Embarcadero\Studio\22.0\CatalogRepository\SynEdit-2022.03-11\". This could take a while...
[2022-08-29 09:29:42] [DEBUG] GetIt: Compiling project "SynEditDR.dproj"...
[2022-08-29 09:29:45] [DEBUG] GetIt: Problem occurred when compiling for "Win64" platform with "Release" configuration.
[2022-08-29 09:29:47] [DEBUG] GetIt: Problem occurred when compiling for "Win64" platform with "Debug" configuration.
[2022-08-29 09:29:48] [DEBUG] GetIt: Problem occurred when compiling for "Win32" platform with "Release" configuration.
[2022-08-29 09:29:50] [DEBUG] GetIt: Problem occurred when compiling for "Win32" platform with "Debug" configuration.
[2022-08-29 09:29:50] [DEBUG] GetIt: Error when executing an action of "SynEdit for VCL" catalog. The action is "CompileProject" (ID 6).
[2022-08-29 09:29:50] [DEBUG] GetIt: A problem occurred during the process.
[2022-08-29 09:32:26] [DEBUG] GetIt: Cancelling process...
===== End =======

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×