Unfortunately I never got the solution as to how we can access the XML ID. I resorted to generating by own id for the layers. It is not exactly an ideal solution but suffices my purpose. Though I would love to know if at all there is a way to extract the unique id .
Not sure if this is what your after, but under Preferences there is an option to "Identify Objects By: Object Name or XML ID"
I only just noticed it so not sure if it helps in any way
I was actually trying to access this unique id using Extendscript. That's where I was stuck as I could not find which property in the Illustrator DOM would give me the value for XML ID.
Hi all, I am sorry to bring about gloom, but it is my opinion that the (Identify by Object Name or XML_ID) is purely for input purposes while you're using Illustrator to draw. The preference controls how you can input new names (Unique name, no spaces, no start with number, etc) and makes changes to existing names to convert to the new preference. The name is now in the format of an XML_ID, so your pageItem.name is still what reflects the object's xml id.
When I found this I noticed it changed the name of the layers in the layers pallet.
I had not had a chance to test this with code.
If "use XML ID" is turned on then you are not able to name layers the same thing.
this in turn would follow through to your script using layer.name
for existing files you would need to fix names manually or...
I am sure it would be possible to Script.
eg. export SVG file and pull the layer ID's from that and rename the document layers accordingly. (may be a little tricky for sublayers, but top level layers should be straight forward)
Then as long as "use XML ID" is left on the files would not need this run again as you cannot use duplicate layer names.