private static string GetTargetNamespace(string schema)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(schema);
if (xd.ChildNodes.Count <= 1)
{
throw new XmlException("Can't find schema element in " + xd.Name);
}
if (xd.ChildNodes[1].Attributes != null)
{
XmlAttributeCollection attributeList = xd.ChildNodes[1].Attributes;
return attributeList["targetNamespace"] == null ? string.Empty : attributeList["targetNamespace"].Value;
}
return null;
}