Forum Discussion
XML parsing in Remote Provisioning ProvisioningTemplate.
Seems SecurityElement.Escape isn't the solution it also replaces <> :(
There's no best practice describing you should not use un-escaped characters. There are some character limitations in naming SharePoint elements but the GetProvisioningTemplate method should just work with any allowed character.
I'd suggest you to submit an issue in the OfficeDevPnP.Core repository on GitHub so you, me or someone else can take a look at it and fix it :-)
https://github.com/SharePoint/PnP-Sites-Core
- Jonathan LoweFeb 23, 2017Copper Contributor
I did more digging and have a better understanding of the issue. In cases where we have a custom column assocaited with a list that has a non xmlable character in it E.g. List title = "2016 R&D", the PNP code will try to put a token into the SourceID to replace the Guid that associates the column with the list. So in this case SourceID was a GUID it becomes "{{listid:{list.Title}}}" which is "listid: 2016 R&D". This can't be handled by xml parser later on when writing it to disk. I am testing a fix that when the PNP code reads the lists from CSOM for the site it fixes up the Title to be xmlable so & becomes & etc... Worked to serialize to disk, am working on the round trip.
private string ParseFieldSchema(string schemaXml, Web web, List<List> lists) { foreach (var list in lists) { schemaXml = Regex.Replace(schemaXml, list.Id.ToString(), $"{{listid:{list.Title}}}", RegexOptions.IgnoreCase); .