[OpenLayers-Users] Parse WMC Extension element for INFO_FORMAT

Semantica jvanulde at nrcan.gc.ca
Tue Nov 25 20:07:10 EST 2008


Found the solution (suggestions for improvement are welcome):

function getInfoFormat(layer) {
  var infoFormat = "text/html";
  var format = new OpenLayers.Format.XML();                     
  var doc =
format.read(document.getElementById('hiddenFieldContainingWMC').value);        
  var layerNodes = format.getElementsByTagNameNS(doc, '*', 'Layer');

  for (var i=0; i<format.getElementsByTagNameNS(doc, '*',
'Layer').length;i++) { 
                
    if(format.getChildValue(format.getElementsByTagNameNS(layerNodes[i],
'*', 'Name')[0]) == layer.params.LAYERS) {    
      var infoFormatNodes = format.getElementsByTagNameNS(layerNodes[i],
'*', 'InfoFormat');                    
      infoFormat = format.getChildValue(infoFormatNodes[0]); 
      }                
    }
            
    return infoFormat;        
}


Semantica wrote:
> 
> Hi all,
> 
> I need to access an Extension element in my WMC that stores the
> INFO_FORMAT for a layer.  
> 
> For example my WMC includes:
> 
> <Layer>
> ..
> <Extension>
>   <px:InfoFormat
> xmlns:px="http://www.someurl/context">text/xml</px:InfoFormat> 
> </Extension>
> ...
> </Layer>
> 
> I can't hardcode the INFO_FORMAT for obvious reasons.  Any ideas on how I
> can access this?
> 
> Thank you in advance!
> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Parse-WMC-Extension-element-for-INFO_FORMAT-tp1500396p1579079.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list