OpenPetra
Free Administration Software for Non-Profits
|
This class provides methods for parsing an XML document and assign the contents to a representation in memory. More...
Public Member Functions | |
TXMLParser (string filename, Boolean withValidation) | |
constructor More... | |
TXMLParser (string filename) | |
constructor; opens the file with validation More... | |
TXMLParser (XmlDocument ADoc) | |
can be used for document that is parsed from YML More... | |
TXMLParser (TXMLParser AReuseParser) | |
copy constructor More... | |
XmlDocument | GetDocument () |
retrieves the document, in case the document should be parsed not by a derived class More... | |
Static Public Member Functions | |
static string | XmlToString (XmlDocument ADoc) |
print an xml document to string; this can be necessary for transmitting between server and client, since XmlDocument is not serializable More... | |
static string | XmlToStringIndented (XmlDocument ADoc) |
print an xml document to string with indentation More... | |
static string | XmlToString2 (XmlDocument ADoc) |
this is necessary to be able to store XML files that can be parsed by DTD/Schema mechanisms; for YML, we have the name of an element not as an attribute, but the element name itself; this would never work for validating xml; therefore all Elements are called XmlElement, with attribute name More... | |
static XmlNode | NextNotBlank (XmlNode cur2) |
test the given node, if it is a comment or is empty; if it is empty, try the next nodes. More... | |
static XmlNode | GetNextEntity (XmlNode cur) |
get the next code that is a proper entity (i.e. no comment, not empty) More... | |
static XmlNode | GetChild (XmlNode cur, string name) |
return the child with the given name, if it exists; otherwise return null More... | |
static XmlNode | FindNodeRecursive (XmlNode AParentNode, string ANodeNameToSearch) |
find a node somewhere in the xml document by its tag name More... | |
static XmlNode | FindNodeRecursive (XmlNode AParentNode, string ANodeNameToSearch, string ANameAttribute) |
find a node somewhere in the xml document by its tag name and attribute name More... | |
static void | SetAttribute (XmlNode cur, string AAttribName, string AAttribValue) |
add or set an attribute value More... | |
static void | RenameAttribute (XmlNode cur, string AAttribOldName, string AAttribNewName) |
rename an existing attribute More... | |
static string | GetAttribute (XmlNode cur, string attrib) |
Retrieve an XML attribute. Empty if attribute is not present More... | |
static string | GetAttributeRecursive (XmlNode cur, string attrib, bool AInheritAttributes) |
Retrieve an XML attribute. Empty if attribute is not present. Check the parent nodes, if the current node does not have that attribute More... | |
static Boolean | HasAttribute (XmlNode cur, string attrib) |
retrieve whether the node has an attribute with the given name or not More... | |
static Int32 | GetIntAttribute (XmlNode cur, string attrib) |
retrieve the int value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing More... | |
static bool | GetBoolAttribute (XmlNode cur, string attrib, bool defaultvalue) |
retrieve the boolean value of an attribute. Understands all sorts of notation (yes|no, true|false, 0|1) More... | |
static bool | GetBoolAttribute (XmlNode cur, string attrib) |
overload for GetBoolAttribute, assuming default value is false More... | |
static double | GetDoubleAttribute (XmlNode cur, string attrib) |
retrieve the double value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing More... | |
static decimal | GetDecimalAttribute (XmlNode cur, string attrib) |
retrieve the decimal value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing More... | |
Protected Attributes | |
XmlDocument | myDoc |
the XmlDocument that is currently parsed More... | |
This class provides methods for parsing an XML document and assign the contents to a representation in memory.
The TXMLParser class provides an easy approach to parse elements and groups of elements of an XML document. It provides functions for easily navigate through an XML document and to retrieve attributes etc. It makes use of the .Net XML parser library.
|
inline |
constructor
filename | |
withValidation |
|
inline |
constructor; opens the file with validation
filename |
|
inline |
can be used for document that is parsed from YML
ADoc | the document that should be parsed |
|
inline |
copy constructor
AReuseParser |
|
inlinestatic |
find a node somewhere in the xml document by its tag name
AParentNode | |
ANodeNameToSearch |
|
inlinestatic |
find a node somewhere in the xml document by its tag name and attribute name
AParentNode | |
ANodeNameToSearch | |
ANameAttribute |
|
inlinestatic |
Retrieve an XML attribute. Empty if attribute is not present
cur | the current node |
attrib | the name of the attribute |
|
inlinestatic |
Retrieve an XML attribute. Empty if attribute is not present. Check the parent nodes, if the current node does not have that attribute
cur | the current node |
attrib | the name of the attribute |
AInheritAttributes | return all the values of the parent nodes as well |
|
inlinestatic |
overload for GetBoolAttribute, assuming default value is false
cur | the current node |
attrib | the name of the attribute |
|
inlinestatic |
retrieve the boolean value of an attribute. Understands all sorts of notation (yes|no, true|false, 0|1)
cur | the current node |
attrib | the name of the attribute |
defaultvalue | the default value if the attribute is not existing; optional: false |
|
inlinestatic |
return the child with the given name, if it exists; otherwise return null
|
inlinestatic |
retrieve the decimal value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing
cur | the current node |
attrib | the name of the attribute |
|
inline |
retrieves the document, in case the document should be parsed not by a derived class
|
inlinestatic |
retrieve the double value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing
cur | the current node |
attrib | the name of the attribute |
|
inlinestatic |
retrieve the int value of an attribute. Does prevent unnecessary exceptions, if the attribute is not existing
cur | the current node |
attrib | the name of the attribute |
|
inlinestatic |
get the next code that is a proper entity (i.e. no comment, not empty)
cur | the current node |
|
inlinestatic |
retrieve whether the node has an attribute with the given name or not
cur | the current node |
attrib | the name of the attribute |
|
inlinestatic |
test the given node, if it is a comment or is empty; if it is empty, try the next nodes.
cur2 | the current node |
|
inlinestatic |
rename an existing attribute
cur | |
AAttribOldName | |
AAttribNewName |
|
inlinestatic |
add or set an attribute value
cur | |
AAttribName | |
AAttribValue |
|
inlinestatic |
print an xml document to string; this can be necessary for transmitting between server and client, since XmlDocument is not serializable
ADoc |
|
inlinestatic |
this is necessary to be able to store XML files that can be parsed by DTD/Schema mechanisms; for YML, we have the name of an element not as an attribute, but the element name itself; this would never work for validating xml; therefore all Elements are called XmlElement, with attribute name
ADoc |
|
inlinestatic |
print an xml document to string with indentation
ADoc |
|
protected |
the XmlDocument that is currently parsed