1 Reply Latest reply on Jan 3, 2007 12:16 PM by ntsiii

    XML namespaces and e4x expressions

    ntsiii Level 3
      I have some WebService e4x formatted result data I am trying to access. Here is a bit of it:
      <GetWeatherByZipCodeResponse xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns=" http://www.webservicex.net" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
      <GetWeatherByZipCodeResult>
      <Latitude>33.57975</Latitude>
      <Longitude>85.08121</Longitude>
      <PlaceName>CARROLLTON</PlaceName>
      .........................

      It has 4 xmlns properties set, one of the is the default.

      Which namespaces do I delclare/use, and how do I reference the <PlaceName> node using e4x? I can get to it using the index:
      sPlaceName = xmlResultNode.children()[2].text();
      but not using the node name:
      sPlaceName = xmlResultNode.PlaceName.text()

      This is clearly a namespace issue, but which namespace?

      Thanks,
      Tracy
        • 1. Re: XML namespaces and e4x expressions
          ntsiii Level 3
          Ok, I figured this case out.

          Notice the xml elements do not have namespace prefixes. This means that they are using the default namespace. So adding this directive:
          default xml namespace = " http://www.webservicex.net";
          allows me to reference the nodes without any namespace problem.

          A related issue: I attempted to use this xml in a datagrid, but found that I could not use dataField, perhaps because of the namespace problem? Anyway, the solution to that was to use a labelFunction.

          I've posted the entire webservice example on CFLEX.net.

          Tracy