Could someone help me out? I'm a bit confused...
This is for a chat server application I have made, and it outputs all information into the chatroom.
This is the code
This is for IP tracing in the chatroom.Code:private void Work() { this.busy = true; try { WebRequest request = WebRequest.Create("http://api.ipinfodb.com/v2/ip_query.php?key=MYKEY&ip=" + this.query); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream, Encoding.Default); String[] lines = reader.ReadToEnd().Split(new String[] { "\n" }, StringSplitOptions.None); TraceObject obj = new TraceObject(); obj.country = lines[4]; obj.region = lines[6]; obj.city = lines[7]; obj.SetTime(lines[9], lines[10]); reader.Close(); stream.Flush(); stream.Close(); response.Close(); UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x000310\x0007Trace Result for: " + this.name)); UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket(" ")); bool color1 = true; if (obj.country.Length > 0) { UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x00030" + (color1 ? "6" : "3") + "Country: " + obj.country)); color1 = !color1; } if (obj.region.Length > 0) { UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x00030" + (color1 ? "6" : "3") + "Region: " + obj.region)); color1 = !color1; } if (obj.city.Length > 0) { UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x00030" + (color1 ? "6" : "3") + "City: " + obj.city)); color1 = !color1; } if (obj.got_time) { UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x00030" + (color1 ? "6" : "3") + "Local Time: " + obj.localtime)); color1 = !color1; } UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket(" ")); UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("\x000310\x0007Trace Complete")); } catch { UserPool.Broadcast(this.vroom, ServerOutboundPackets.AnnoucePacket("Unable to trace a result for " + this.name)); } this.busy = false; } }
When an admin in the chatroom sends the trace command, it processes this command.
It utilizes the site
http://api.ipinfodb.com/v2/ip_query.php?key=MYKEY&ip=
It automatically plugs in an IP address.
It returns results with absolutely no problems.
The only thing is...
How do I strip out the tags, immediately after it grabs the information, before processing it into the chatroom?
I want "<CountryName/>", "<RegionName/>", and "<City/>" to be stripped out... So it only shows the information I want...
As of now, this is how it outputs into the chatroom:
Trace Result for: (ip removed, u dont need my ip)
Country: <CountryName>United States</CountryName>
Region: <RegionName>Virginia</RegionName>
City: <City>Norfolk</City>
Trace Complete


LinkBack URL
About LinkBacks


Reply With Quote


