[mapguide-users] Custom Search

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Fri Jan 30 03:50:44 EST 2009


Yes, but once you have the full Xml, you can load it into an Xml parser.
It looks like you are using C#, so the code would be:

XmlDocument doc = new XmlDocument();
doc.LoadXml(rd.ToString());
XmlNode node = doc.SelectSingleNode("xs:Filter", namespacemanager); 
//You need to setup the namespace manager.
string filter = node.InnerText; //Here it is

If you are using C#, you may want to look at the MaestroAPI:
http://trac.osgeo.org/mapguide/wiki/maestro/MaestroAPI

Using the MaestroAPI, you can read the filter like this:

ServerConnectionI con; //Read the docs on how to initialize this
LayerDefinition ldef = con.GetLayerDefinition("Library://" + 
myLayer.GetLayerDefinition().GetPath() + "/" + myLayer.GetName() + 
".LayerDefinition");
VectorLayerDefinition vldef = ldef.Item as VectorLayerDefinition;
string filter = vldef.Filter; //Here it is

IMO, much easier, and no use of the Mg* classes.

Regards, Kenneth Skovhede, GEOGRAF A/S



Jamo skrev:
> Kenneth,
>
> Thanks for the response, I am still working on my programming I am unsure on
> how to read through what I belive is a mgByteReader that the resource
> retrieves?
>
> perhaps I can use the mgLayer.SelectFeatures(mgQueryOptions) however this
> returns a null exception... :(
>
>               MgResourceIdentifier myresrc = new
> MgResourceIdentifier("Library://" + myLayer.GetLayerDefinition().GetPath() +
> "/" + myLayer.GetName() + ".LayerDefinition");
>               MgByteReader rd = resourceSrvc.GetResourceContent(myresrc);
>
> Response.Write(EscapeForHtml(rd.ToString()));
>
> This writes out the entire XML File... how can I just return the Filter ? or
> do I have to do some string work here?
>   


More information about the mapguide-users mailing list