JCWEBHOST
asked on
xml
Hey guys, i can not get the nodes text from my xml document?
here is the document innerxml
<marker id="1" r_name="Rit Restaurant" address="232 Canehaven drive" area="ROSSLYN" location="ERASMUS VILLAGE" p_code="0250" Latitude="-25.6236510" Longitude="28.0887790" />
here is my c# code :
XmlDocument Document = new XmlDocument();
Document = XmlData(Latitude, Longitude);
if (Document != null)
{
XmlNodeList nodeList = Document.SelectNodes("mark ers");
foreach (XmlNode node in nodeList)
{
string address = node.SelectSingleNode("add ress").Inn erText;
}
}
please help?
i cant get the address?
here is the document innerxml
<marker id="1" r_name="Rit Restaurant" address="232 Canehaven drive" area="ROSSLYN" location="ERASMUS VILLAGE" p_code="0250" Latitude="-25.6236510" Longitude="28.0887790" />
here is my c# code :
XmlDocument Document = new XmlDocument();
Document = XmlData(Latitude, Longitude);
if (Document != null)
{
XmlNodeList nodeList = Document.SelectNodes("mark
foreach (XmlNode node in nodeList)
{
string address = node.SelectSingleNode("add
}
}
please help?
i cant get the address?
ASKER
here my code:
public void searchLocationsNear(GeoCod e latlng)
{
double Latitude = latlng.Placemark.coordinat es.lat;
double Longitude = latlng.Placemark.coordinat es.lng;
XmlDocument Document = new XmlDocument();
Document = XmlData(Latitude, Longitude);
if (Document != null)
{
XmlNodeList nodeList = Document.SelectNodes("mark ers");
foreach (XmlNode node in nodeList)
{
string address = node.SelectSingleNode("add ress").Inn erText;
}
}
}
public XmlDocument XmlData(double dmlSearchLatitude, double dmlSearchLongitude)
{
m.DmlSearchLatitude = dmlSearchLatitude;
m.DmlSearchLongitude = dmlSearchLongitude;
m.Area = ddArea.SelectedItem.Text;
XmlReader rdrXMLLocations = null;
rdrXMLLocations = m.proc_Location_List();
Response.Expires = 0;
Response.ContentType = "text/xml";
XmlDocument oDocument = new XmlDocument();
System.Text.StringBuilder sb = new System.Text.StringBuilder( );
using (rdrXMLLocations)
{
while (!rdrXMLLocations.EOF)
{
rdrXMLLocations.MoveToCont ent();
sb.Append(rdrXMLLocations. ReadOuterX ml());
}
rdrXMLLocations.Close();
}
oDocument.LoadXml(sb.ToStr ing());
return oDocument;
}
public void searchLocationsNear(GeoCod
{
double Latitude = latlng.Placemark.coordinat
double Longitude = latlng.Placemark.coordinat
XmlDocument Document = new XmlDocument();
Document = XmlData(Latitude, Longitude);
if (Document != null)
{
XmlNodeList nodeList = Document.SelectNodes("mark
foreach (XmlNode node in nodeList)
{
string address = node.SelectSingleNode("add
}
}
}
public XmlDocument XmlData(double dmlSearchLatitude, double dmlSearchLongitude)
{
m.DmlSearchLatitude = dmlSearchLatitude;
m.DmlSearchLongitude = dmlSearchLongitude;
m.Area = ddArea.SelectedItem.Text;
XmlReader rdrXMLLocations = null;
rdrXMLLocations = m.proc_Location_List();
Response.Expires = 0;
Response.ContentType = "text/xml";
XmlDocument oDocument = new XmlDocument();
System.Text.StringBuilder sb = new System.Text.StringBuilder(
using (rdrXMLLocations)
{
while (!rdrXMLLocations.EOF)
{
rdrXMLLocations.MoveToCont
sb.Append(rdrXMLLocations.
}
rdrXMLLocations.Close();
}
oDocument.LoadXml(sb.ToStr
return oDocument;
}
OK, and why did you post that code ??
repeat:
>> Document.SelectNodes("markers");
>> <marker id="1"...
I suspect the SelectNodes isn't correct, or is some XML missing ?
repeat:
>> Document.SelectNodes("markers");
>> <marker id="1"...
I suspect the SelectNodes isn't correct, or is some XML missing ?
Or put another way the code you posted in the question look rather like:
Hi, I want to find objects of type X with the following code, by the way this is how some other object of type A is defined...
Hi, I want to find objects of type X with the following code, by the way this is how some other object of type A is defined...
ASKER
here my xml
(Document).InnerXml
vaule
<markers><marker id="1" r_name="Rit Restaurant" address="232 Canehaven drive" area="ROSSLYN" location="ERASMUS VILLAGE" p_code="0250" Latitude="-25.6236510" Longitude="28.0887790" /></markers>
(Document).InnerXml
vaule
<markers><marker id="1" r_name="Rit Restaurant" address="232 Canehaven drive" area="ROSSLYN" location="ERASMUS VILLAGE" p_code="0250" Latitude="-25.6236510" Longitude="28.0887790" /></markers>
ASKER
thats my full xml document
ASKER
here is my javascript which i am trying to convert to c# code:
var markers = xml.documentElement.getElementsByTagName('marker');
if (markers.length == 0)
{
sidebar.innerHTML = 'No results found. Please try widening your search area.';
map.setCenter(new GLatLng(startingLat, startingLng), startingZoom);
return;
}
var bounds = new GLatLngBounds();
for (var i = 0; i < markers.length; i++)
{
var address = markers[i].getAttribute('address');
var area = markers[i].getAttribute('area');
var location = markers[i].getAttribute('location');
var p_code = markers[i].getAttribute('p_code');
var point = new GLatLng(parseFloat(markers[i].getAttribute('Latitude')), parseFloat(markers[i].getAttribute('Longitude')));
var marker = createMarker(point, address, area, location, p_code);
map.addOverlay(marker);
var sidebarEntry = createSidebarEntry(marker, address, area, location);
sidebar.appendChild(sidebarEntry);
bounds.extend(point);
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
node.Attributes("address")
Not working getting null ref to object
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
>> <marker id="1"...
I suspect the SelectNodes isn't correct, or is some XML missing ?