using System.Collections;
|
|
|
|
namespace BWP.ABCClient.Businesses
|
|
{
|
|
|
|
public class XmlDocument
|
|
{
|
|
private string _xmlString;
|
|
|
|
public XmlDocument()
|
|
{
|
|
_xmlString = "";
|
|
}
|
|
|
|
public XmlDocument(string xmlString)
|
|
{
|
|
_xmlString = "";
|
|
Init(xmlString);
|
|
}
|
|
|
|
public XmlDocument DeleteFirstTagDocument()
|
|
{
|
|
string str = GetFirstTagName();
|
|
int index = _xmlString.IndexOf("<" + str + ">");
|
|
int num2 = _xmlString.IndexOf("</" + str + ">");
|
|
if (num2 > index) {
|
|
_xmlString = _xmlString.Substring((num2 + str.Length) + 3);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public ArrayList GetDocuments(string aTag)
|
|
{
|
|
string xmlString = _xmlString;
|
|
var list = new ArrayList();
|
|
while (true) {
|
|
int index = xmlString.IndexOf("<" + aTag.Trim() + ">");
|
|
int num2 = xmlString.IndexOf("</" + aTag.Trim() + ">");
|
|
if (((index == -1) || (num2 == -1)) || (index > num2)) {
|
|
return list;
|
|
}
|
|
var document = new XmlDocument(xmlString.Substring(index, ((num2 + aTag.Length) + 3) - index));
|
|
list.Add(document);
|
|
xmlString = xmlString.Substring(num2 + 1);
|
|
}
|
|
}
|
|
|
|
public string GetFirstTagName()
|
|
{
|
|
string str = null;
|
|
int index = _xmlString.IndexOf('<');
|
|
int num2 = _xmlString.IndexOf('>');
|
|
if (num2 > index) {
|
|
str = _xmlString.Substring(index + 1, num2 - (index + 1));
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public XmlDocument GetFormatDocument(string aSpace)
|
|
{
|
|
return GetFormatDocument(0, aSpace);
|
|
}
|
|
|
|
private XmlDocument GetFormatDocument(int aLevel, string aSpace)
|
|
{
|
|
string str2;
|
|
string str = aSpace;
|
|
for (int i = 0; i < aLevel; i++) {
|
|
str = str + aSpace;
|
|
}
|
|
if (GetFirstTagName() == null) {
|
|
return this;
|
|
}
|
|
string xmlString = "\n";
|
|
for (var document = new XmlDocument(_xmlString); (str2 = document.GetFirstTagName()) != null; document = document.DeleteFirstTagDocument()) {
|
|
var document2 = document.GetValue(str2);
|
|
var str4 = "";
|
|
if (document2.GetFirstTagName() != null) {
|
|
str4 = str;
|
|
}
|
|
xmlString = string.Concat(new object[] { xmlString, str, "<", str2, ">", document2.GetFormatDocument(aLevel + 1, aSpace), str4, "</", str2, ">\n" });
|
|
}
|
|
return new XmlDocument(xmlString);
|
|
}
|
|
|
|
public XmlDocument GetValue(string aTag)
|
|
{
|
|
XmlDocument document = null;
|
|
int index = _xmlString.IndexOf("<" + aTag.Trim() + ">");
|
|
int num2 = _xmlString.IndexOf("</" + aTag.Trim() + ">");
|
|
if (((index >= 0) && (num2 >= 0)) && (index < num2)) {
|
|
document = new XmlDocument(_xmlString.Substring((index + aTag.Length) + 2, num2 - ((index + aTag.Length) + 2)));
|
|
}
|
|
return document;
|
|
}
|
|
|
|
public virtual string GetValueNoNull(string aTag)
|
|
{
|
|
var str = "";
|
|
var document = GetValue(aTag);
|
|
if (document != null) {
|
|
str = document.ToString();
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public XmlDocument Init(string xmlString)
|
|
{
|
|
_xmlString = xmlString;
|
|
return this;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return _xmlString;
|
|
}
|
|
}
|
|
}
|