EDN Admin
Well-known member
I believe that Im trying to do something incredibly simple. Yet, I cant figure out a clean way to do it. I have some XML that looks like this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ISO-8859-1<span style="color:Black; " <span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; Response <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; " <span style="color:Red; xsi:noNamespaceSchemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.somedomain.com/Response.xsd<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ID<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >John Smith<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Latitude<span style="color:Blue; >41.365736<span style="color:Blue; </<span style="color:#A31515; Latitude<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Longitude<span style="color:Blue; >-82.511756<span style="color:Blue; </<span style="color:#A31515; Longitude<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ID<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >Bill Appleseed<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Latitude<span style="color:Blue; >31.164736<span style="color:Blue; </<span style="color:#A31515; Latitude<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Longitude<span style="color:Blue; >-72.611356<span style="color:Blue; </<span style="color:#A31515; Longitude<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Response<span style="color:Blue; >
[/code]
I need to parse this XML and load it into some CLR objects. Currently, Im doing the following:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; string response = GetXml();
XDocument xml = XDocument.Parse(response);
[/code]
Beyond that, Im stuck. No matter what I try, I get some error. Either a null pointer exception or something else. Can someone show me how you would tackle this problem?
Thanks!
View the full article
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; ISO-8859-1<span style="color:Black; " <span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; Response <span style="color:Red; xmlns:xsi<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.w3.org/2001/XMLSchema-instance<span style="color:Black; " <span style="color:Red; xsi:noNamespaceSchemaLocation<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://www.somedomain.com/Response.xsd<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ID<span style="color:Blue; >1<span style="color:Blue; </<span style="color:#A31515; ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >John Smith<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Latitude<span style="color:Blue; >41.365736<span style="color:Blue; </<span style="color:#A31515; Latitude<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Longitude<span style="color:Blue; >-82.511756<span style="color:Blue; </<span style="color:#A31515; Longitude<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ID<span style="color:Blue; >2<span style="color:Blue; </<span style="color:#A31515; ID<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Name<span style="color:Blue; >Bill Appleseed<span style="color:Blue; </<span style="color:#A31515; Name<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Latitude<span style="color:Blue; >31.164736<span style="color:Blue; </<span style="color:#A31515; Latitude<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Longitude<span style="color:Blue; >-72.611356<span style="color:Blue; </<span style="color:#A31515; Longitude<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Result<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Response<span style="color:Blue; >
[/code]
I need to parse this XML and load it into some CLR objects. Currently, Im doing the following:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; string response = GetXml();
XDocument xml = XDocument.Parse(response);
[/code]
Beyond that, Im stuck. No matter what I try, I get some error. Either a null pointer exception or something else. Can someone show me how you would tackle this problem?
Thanks!
View the full article