[mapguide-users] Finding list of Mapdefinitions

Dave Wilson dave.wilson at autodesk.com
Tue Dec 12 18:44:38 EST 2006


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
	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
	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/434bf270/attachment.html


More information about the Mapguide-users mailing list