XML file class.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(xml_tag), | private, | allocatable | :: | tag(:) |
XML tags array. |
||
integer(kind=I4P), | private | :: | nt | = | 0_I4P |
Number of XML tags. |
Return tag content of tag named name.
Return tag content of tag named name.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(in) | :: | self |
XML file. |
||
character(len=*), | intent(in) | :: | name |
Tag name. |
Tag content.
Add tag from XML file.
Delete tag from XML file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(inout) | :: | self |
XML file. |
||
character(len=*), | intent(in) | :: | name |
XML tag name. |
Parse xml file.
Parse xml data from string or file. XML data is linearized, a DOM structured is used.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(inout) | :: | self |
XML file. |
||
character(len=*), | intent(in), | optional | :: | string |
String containing xml data. |
|
character(len=*), | intent(in), | optional | :: | filename |
File name containing xml data. |
Convert the whole file data into a string.
Convert the whole file data into a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(in) | :: | self |
XML file. |
||
logical, | intent(in), | optional | :: | linearize |
Return a "linearized" string of tags without the XML hieararchy. |
Output string containing the whole xml file.
Add child ID to tag children list.
Add child ID to tag children list.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(inout) | :: | self |
XML file handler. |
||
integer(kind=I4P), | intent(in) | :: | parent_id |
Parent ID. |
||
integer(kind=I4P), | intent(in) | :: | child_id |
Child ID. |
Parse xml data from string.
Parse xml data from a chunk of source string (file stringified for IO on device).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(inout) | :: | self |
XML file handler. |
||
character(len=*), | intent(in) | :: | source_string |
String containing xml data. |
Convert recursively tags with children into a string.
Convert recursively tags with children into a string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(xml_file), | intent(in) | :: | self |
XML file. |
||
type(xml_tag), | intent(in) | :: | tag |
XML tag with children. |
||
logical, | intent(inout) | :: | is_done(:) |
List of stringified tags. |
||
character(len=:), | intent(inout), | allocatable | :: | tag_string |
Output string containing the current tag. |
type, public:: xml_file !< XML file class. private type(xml_tag), allocatable :: tag(:) !< XML tags array. integer(I4P) :: nt=0_I4P !< Number of XML tags. contains ! public methods procedure, pass(self) :: add_tag !< Add tag to XML file. procedure, pass(self) :: content !< Return tag content of tag named *name*. procedure, pass(self) :: delete_tag !< Add tag from XML file. procedure, pass(self) :: free !< Free dynamic memory. procedure, pass(self) :: parse !< Parse xml file. procedure, pass(self) :: stringify !< Convert the whole file data into a string. ! private methods procedure, pass(self), private :: add_child !< Add child ID to tag children list. procedure, pass(self), private :: parse_from_string !< Parse xml data from string. procedure, pass(self), private :: stringify_recursive !< Convert recursively tags with children into a string. ! operators final :: finalize !< Free dynamic memory when finalizing. endtype xml_file