मुझे अभी भी यकीन नहीं है कि क्या आप सिर्फ यह जानना चाहते हैं कि एक्सपैथ में नेमस्पेस है या आप नामस्थान के संदर्भों को हटाना चाहते हैं या नहीं। तो यहां कुछ नमूना कोड (सी # में) है जो दोनों करता है।
class Program
{
static void Main(string[] args)
{
string withNamespace = @"//foo/ns2:bar/baz[1]/ns:foo2/@attr/text()";
string withoutNamespace = @"//foo/bar/baz[1]/foo2/@attr/text()";
ShowStuff(withNamespace);
ShowStuff(withoutNamespace);
}
static void ShowStuff(string input)
{
Console.WriteLine("'{0}' does {1}contain namespaces", input, ContainsNamespace(input) ? "" : "not ");
Console.WriteLine("'{0}' without namespaces is '{1}'", input, StripNamespaces(input));
}
static bool ContainsNamespace(string input)
{
//a namspace must start with a character, but can have characters and numbers
//from that point on.
return Regex.IsMatch(input, @"/?\w[\w\d]+:\w[\w\d]+/?");
}
static string StripNamespaces(string input)
{
return Regex.Replace(input, @"(/?)\w[\w\d]+:(\w[\w\d]+)(/?)", "$1$2$3");
}
}
उम्मीद है की वो मदद करदे! सौभाग्य।