Using OmniXML package, is it possible to store XML code inside another XML file that has its own XML data?
Like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<data>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<otherxml>data</otherxml>
</data>
where inside the tag data, everything should be data. Is there an escape char that prevent the parser from parsing the next data into the XML data structure?
Or Does OmniXML comes with support for serialization for this situation?
Any other simple ideas are also welcome.
XML documents you insert into columns of type XML can reside either in the default storage object, or directly in the base table row. Base table row storage is under your control and is available only for small documents; larger documents are always stored in the default storage object.
The ampersand character (&) starts entity markup (the first character of a character entity reference). > The greater-than character (>) ends a start-tag or an end-tag.
The term CDATA means, Character Data. CDATA is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup. The predefined entities such as <, >, and & require typing and are generally difficult to read in the markup. In such cases, CDATA section can be used.
To avoid errors, you should specify the encoding used, or save your XML files as UTF-8. UTF-8 is the default character encoding for XML documents. Character encoding can be studied in our Character Set Tutorial. UTF-8 is also the default encoding for HTML5, CSS, JavaScript, PHP, and SQL.
You can use CDATA:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<data>
<![CDATA[
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<otherxml>data</otherxml>
]]>
</data>
Note when you get the value for data
, it will be as a string so you'd have to run it through a new XML parser.
Here is an example code for omniXML:
var
xml:IXMLDocument;
Node:IXMLNode;
begin
xml := CreateXMLDoc;
xml.SelectSingleNode('/root/data',Node);
ShowMessage(GetNodeCData(Node,'data',''));
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With