public string
GetIPLocation
()
{
string
address =
string
.Empty;
string
ipAddress =
GetIPAddress
();
string
xmlString =
IPRequestHelper
(
"
http://ip-api.com/xml/
"
+ ipAddress);
if
(
string
.
IsNullOrEmpty
(xmlString))
{
XmlDocument
xdoc =
new
XmlDocument
();
xdoc.
LoadXml
(xmlString);
XmlNode
statusNode = xdoc.
SelectSingleNode
(
"/query/"
+
"status"
);
if
(statusNode.InnerText ==
"success"
)
{
XmlNode
cityNode = xdoc.
SelectSingleNode
(
"/query/"
+
"city"
);
XmlNode
regionNameNode = xdoc.
SelectSingleNode
(
"/query/"
+
"regionName"
);
XmlNode
regionNode = xdoc.
SelectSingleNode
(
"/query/"
+
"region"
);
XmlNode
countryNode = xdoc.
SelectSingleNode
(
"/query/"
+
"country"
);
XmlNode
countryCodeNode = xdoc.
SelectSingleNode
(
"/query/"
+
"countryCode"
);
address = cityNode.InnerText +
", "
;
address += regionNameNode.InnerText +
" ("
+ regionNode.InnerText +
"), "
;
address += countryNode.InnerText +
" ("
+ countryCodeNode.InnerText +
")"
;
}
}
return
address;
}