[mapguide-users] Finding list of Mapdefinitions

Scott Reisdorf reisdorf1 at llnl.gov
Tue Dec 12 18:51:35 EST 2006


And heres some parsing of XML in Java:

 MgByteReader byteReader = 
resourceService.EnumerateResources(resId,-1,MgResourceType.MapDefinition);
        String xml = byteReader.ToString();

           DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();
           DocumentBuilder builder = factory.newDocumentBuilder();
           Document document = builder.parse(new InputSource(new 
StringReader(xml)));
          
           NodeList nodes = document.getElementsByTagName("ResourceId");
           for(int i=0;i<nodes.getLength(); i++) {
               Node resNode = nodes.item(i);
               String node = resNode.getFirstChild().getNodeValue();
                //...
             }


-scott

Dave Wilson wrote:
> Here's a tiny excerpt of some DOM parsing in PHP. I haven't don't much.
>  
> Assuming you have saved the XML to $mapXml:
>  
> $doc = DOMDocument::loadXML($mapXml);
>         $mapNode = $doc->getElementsByTagName('ResourceId')->item(0);
>         $mapName = $mapNode->nodeValue;
>  
> Of course you probably need a loop to determine vary item(x). Not sure 
> how you do a while or find the max item(x) in XML.
>  
> Dave
>
> *From:* Dave Wilson
> *Sent:* Tuesday, December 12, 2006 4:21 PM
> *To:* users at mapguide.osgeo.org
> *Subject:* RE: [mapguide-users] Finding list of Mapdefinitions
>
> Thanks Scott. Beat me to it.
>  
> With the DOM parser you can search on the <ResourceId> tag and parse 
> the name of the map, here's an example value:
>  
> <ResourceId>Library://QE_Data/Maps/SDF2.0_Dublin_CA83IIIF.MapDefinition</ResourceId> 
>
>  
> By the way it's Library://
>  
> // and not \\ just in case you missed that too.
>  
> Dave
>
> *From:* Scott Reisdorf [mailto:reisdorf1 at llnl.gov]
> *Sent:* Tuesday, December 12, 2006 4:18 PM
> *To:* users at mapguide.osgeo.org
> *Subject:* Re: [mapguide-users] Finding list of Mapdefinitions
>
> In Java you can do something like this, creating a 
> ByteArrayOutputStream and then displaying that stream back as a String.
>
>
>  ByteArrayOutputStream bos = new ByteArrayOutputStream();       
>         byte[] byteBuffer = new byte[1024];
>         int numBytes = byteReader.Read(byteBuffer, 1024);
>         while(numBytes > 0)
>         {
>             bos.write(byteBuffer, 0, numBytes);
>             numBytes = byteReader.Read(byteBuffer, 1024);
>         }
>         System.out.println(bos.toByteArray());
>
>
> or you can get straight XML back from the MgByteReader, and then parse 
> that:
>
>   MgByteReader byteReader = 
> resourceService.EnumerateResources(resId,-1,MgResourceType.MapDefinition);
>         String xml = byteReader.ToString();
>    //  ...parse the xml via the DOM
>
> hope this helps
> -scott
>
> Scott Hameister wrote:
>>
>> Did that, but I get an MgByteReader object with no clue how to 
>> iterate...isn't there a count/getitem method I could use or do I have 
>> to convert to a string and Parse or something?
>>
>> * From: * Dave Wilson [mailto:dave.wilson at autodesk.com]
>> *Sent:* Tuesday, December 12, 2006 4:54 PM
>> *To:* users at mapguide.osgeo.org <mailto:users at mapguide.osgeo.org>
>> *Subject:* RE: [mapguide-users] Finding list of Mapdefinitions
>>
>> Try MapDefinition
>>
>> Case sensitive.
>>
>> :)
>>
>> * From: * Scott Hameister [mailto:ScottH at mPower-tech.com]
>> *Sent:* Tuesday, December 12, 2006 3:53 PM
>> *To:* users at mapguide.osgeo.org <mailto:users at mapguide.osgeo.org>
>> *Subject:* [mapguide-users] Finding list of Mapdefinitions
>>
>> Pulling my Hair out I'm just trying to get a list of Mapdefinitions 
>> in the Library:\\
>>
>> I tried doing EnumerateResources on Library\\: with -1 and 
>> Mapdefinition, but can't find an API way to get the names....Am I way 
>> off target here?
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20061212/2824949e/attachment.html


More information about the Mapguide-users mailing list