namespace com.hitrust.b2b.trustpay.client
|
|
{
|
|
using System;
|
|
using System.Collections;
|
|
|
|
public class XMLDocument
|
|
{
|
|
private string iXMLString;
|
|
|
|
public XMLDocument()
|
|
{
|
|
this.iXMLString = "";
|
|
}
|
|
|
|
public XMLDocument(string aXMLString)
|
|
{
|
|
this.iXMLString = "";
|
|
this.init(aXMLString);
|
|
}
|
|
|
|
public virtual XMLDocument deleteFirstTagDocument()
|
|
{
|
|
string str = this.getFirstTagName();
|
|
int index = this.iXMLString.IndexOf("<" + str + ">");
|
|
int num2 = this.iXMLString.IndexOf("</" + str + ">");
|
|
if (num2 > index)
|
|
{
|
|
this.iXMLString = this.iXMLString.Substring((num2 + str.Length) + 3);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
public virtual ArrayList getDocuments(string aTag)
|
|
{
|
|
string iXMLString = this.iXMLString;
|
|
ArrayList list = new ArrayList();
|
|
while (true)
|
|
{
|
|
XMLDocument document = null;
|
|
int index = iXMLString.IndexOf("<" + aTag.Trim() + ">");
|
|
int num2 = iXMLString.IndexOf("</" + aTag.Trim() + ">");
|
|
if (((index == -1) || (num2 == -1)) || (index > num2))
|
|
{
|
|
return list;
|
|
}
|
|
document = new XMLDocument(iXMLString.Substring(index, ((num2 + aTag.Length) + 3) - index));
|
|
list.Add(document);
|
|
iXMLString = iXMLString.Substring(num2 + 1);
|
|
}
|
|
}
|
|
|
|
public virtual string getFirstTagName()
|
|
{
|
|
string str = null;
|
|
int index = this.iXMLString.IndexOf('<');
|
|
int num2 = this.iXMLString.IndexOf('>');
|
|
if (num2 > index)
|
|
{
|
|
str = this.iXMLString.Substring(index + 1, num2 - (index + 1));
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public virtual XMLDocument getFormatDocument(string aSpace)
|
|
{
|
|
return this.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 (this.getFirstTagName() == null)
|
|
{
|
|
return this;
|
|
}
|
|
string aXMLString = "\n";
|
|
for (XMLDocument document = new XMLDocument(this.iXMLString); (str2 = document.getFirstTagName()) != null; document = document.deleteFirstTagDocument())
|
|
{
|
|
XMLDocument document2 = document.getValue(str2);
|
|
string str4 = "";
|
|
if (document2.getFirstTagName() != null)
|
|
{
|
|
str4 = str;
|
|
}
|
|
aXMLString = string.Concat(new object[] { aXMLString, str, "<", str2, ">", document2.getFormatDocument(aLevel + 1, aSpace), str4, "</", str2, ">\n" });
|
|
}
|
|
return new XMLDocument(aXMLString);
|
|
}
|
|
|
|
public virtual XMLDocument getValue(string aTag)
|
|
{
|
|
XMLDocument document = null;
|
|
int index = this.iXMLString.IndexOf("<" + aTag.Trim() + ">");
|
|
int num2 = this.iXMLString.IndexOf("</" + aTag.Trim() + ">");
|
|
if (((index >= 0) && (num2 >= 0)) && (index < num2))
|
|
{
|
|
document = new XMLDocument(this.iXMLString.Substring((index + aTag.Length) + 2, num2 - ((index + aTag.Length) + 2)));
|
|
}
|
|
return document;
|
|
}
|
|
|
|
public virtual string getValueNoNull(string aTag)
|
|
{
|
|
string str = "";
|
|
XMLDocument document = this.getValue(aTag);
|
|
if (document != null)
|
|
{
|
|
str = document.ToString();
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public XMLDocument init(string aXMLString)
|
|
{
|
|
this.iXMLString = aXMLString;
|
|
return this;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.iXMLString;
|
|
}
|
|
}
|
|
}
|
|
|