asp.net - Using SelectSingleNode with XML file, node repeats twice -


Here's a file I'm trying to parse I & lt; CountryName & gt; and & lt; CountryAbbrev & gt; You can get data from , but & lt; Gml: name & gt; node Note that this node in the XML file twice, at the top level and & lt; Hostip & gt; Appears under node, it is a syntax I am using:

  • It does one thing - Doctor Selected SINGLANOD ("//" Country Name ")
  • Does it work? Any ideas?
      & lt; HostipLookupResultSet xmlns:    GML = "http://www.opengis.net/gml" xmlns: xsi = "http://www.w3.org/2001/ XMLSchema-instance "version =" 1.0.1 "xsi: a namespace location location =" http: //www.hostip.info/api/hostip-1.0.1.xsd"> & Lt; Gml: description & gt; This host Lookup service & lt; / Gml: description & gt; & Lt; GML: Name & gt; Hostip & lt; / GML: Name & gt; & Lt; GML: boundedBy & gt; & Lt; GML: Null & gt; Inappropriate & lt; / GML: Null & gt; & Lt; / GML: boundedBy & gt; & Lt; GML: featureMember & gt; & Lt; Hostip & gt; & Lt; IP & gt; 24.205.216.31 & lt; / IP & gt; & Lt; Gml: name & gt; Carson City, NV & lt; / Gml: name & gt; & Lt; Country & gt; United Nations & lt; / CountryName & gt; & Lt; CountryAbbrev & gt; America & lt; / CountryAbbrev> & Lt; IpLocation & gt; & Lt; GML: pointProperty & gt; & Lt; Gml: point srsName = "http://www.opengis.net/gml/srs/epsg.xml#4326" & gt; & Lt; GML: Coordinate & gt; -119.763,39.233 & lt; / GML: Coordinate & gt; & Lt; / GML: Point & gt; & Lt; / GML: pointProperty & gt; & Lt; / IpLocation & gt; & Lt; / Hostip & gt; & Lt; / GML: featureMember & gt; & Lt; / HostipLookupResultSet>    

    You will need to use it for xmlns alias < Code> GML . Try doing this:

      XmlNamespaceManager nsmanager = New XmlNamespaceManager (doc.NameTable); Nsmanager.AddNamespace ("gml", "http://www.opengis.net/gml"); Debug.WriteLine (doc.SelectSingleNode ("// Country Name") innerText.); Foreach (Xmlnode node in the doctor. Selection nodes ("// gml: name", nsmanager) {Debug.WriteLine (node. INTERTEX); }   

    Result:

      United States Hosts Carson City, NV   

    Edit < / Strong>

    Only one idea, if you are just trying to use one of the gml: name nodes, then the following xpaths are respectively for the first and second one Sub-projection will:

      // HostPooseUpsetSetset / GML: Name / Text () // Hosted LookupRetsetset / GML: Feature Mail / GML: Name / Hostname / Text ()    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -