Parsing XML Links in Delphi

I used the Delphi 2006 Data Binding Wizard to create an interface for the XML configuration file. Later, I realized that some duplicate parts of XML can be separated from the main file and pointed out where necessary. The resulting XML looks something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module [
<!ENTITY Schema65 SYSTEM "schemas/65.xml">
]>
<module>
  <schema>&Schema65;</schema>
</module>

If I open this file using Internet Explorer, the contents of the placeholder "& Schema65;" It is correctly replaced by the contents of the external file. However, the Delphi analyzer does not seem to recognize this function and does not replace the text. Any idea how to solve this problem?

+3
source share
4 answers

Internet Explorer, , MSXML. TXmlDocument.DomVendor MSXML_DOM ( msxmldom), . DefaultDOMVendor SMSXML, TXmlDocument .

+2

OmniXML? , XML . , : , .

+1

Internet Explorer XmlResolver. XmlResolver XmlDocument XmlDocument , XML , (DTD), . (URI). XmlDocument EntityReference, , DTD .

delphi, .

Open XML , TStandardResourceResolver

Bye.

+1

. , Delphi (MSXML) , - .

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module [
<!ENTITY Schema65 SYSTEM "schemas/65.xml">
]>
<module>
  <schema>&Schema65;</schema>
</module>

, TXMLDocument , :

MyXML := TXMLDOcument.Create(myfile.xml);
ExternalText := MyXML.documentElement.ChildNodes['schema'].Text;

, . Delphi "ntEntityRef" "" node. node , , , , . :

MyXML.documentElement.ChildNodes['schema'].FirstChild.FirstChild.Text;

If the external object file contains a node structure, the corresponding nodes will be created inside the reference to the node object. Make sure TXMLDocument.ParseOptions is set to at least [poResolveExternals]. This approach also simplifies the adaptation of the code generated by the XML Data Binding Wizard to work with external objects.

+1
source

Source: https://habr.com/ru/post/1717451/


All Articles