mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
* Minor: Insert utility function to format raw xml strings into indented xml for debugging purposes
This commit is contained in:
@@ -36,6 +36,7 @@ using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using libsecondlife;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
@@ -43,6 +44,9 @@ using Nwc.XmlRpc;
|
||||
|
||||
namespace OpenSim.Framework
|
||||
{
|
||||
/// <summary>
|
||||
/// Miscellaneous utility functions
|
||||
/// </summary>
|
||||
public class Util
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
@@ -161,6 +165,36 @@ namespace OpenSim.Framework
|
||||
// (but those probably wont work anyway)
|
||||
return file;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Debug utility function to convert unbroken strings of XML into something human readable for occasional debugging purposes.
|
||||
///
|
||||
/// Please don't delete me even if I appear currently unused!
|
||||
/// </summary>
|
||||
/// <param name="rawXml"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetFormattedXml(string rawXml)
|
||||
{
|
||||
XmlDocument xd = new XmlDocument();
|
||||
xd.LoadXml(rawXml);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
StringWriter sw = new StringWriter(sb);
|
||||
|
||||
XmlTextWriter xtw = new XmlTextWriter(sw);
|
||||
xtw.Formatting = Formatting.Indented;
|
||||
|
||||
try
|
||||
{
|
||||
xd.WriteTo(xtw);
|
||||
}
|
||||
finally
|
||||
{
|
||||
xtw.Close();
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static bool IsEnvironmentSupported(ref string reason)
|
||||
{
|
||||
@@ -634,4 +668,4 @@ namespace OpenSim.Framework
|
||||
return client.Send(url, 6000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user