I am doing metadata update for Pages as below. I am constantly getting the below error
XML validation error. Reason: The required attribute 'http://www.w3.org/1999/xlink:href' is missing..
Code is below.
XElement xMetadata = XElement.Parse(pageData.Metadata);
XNamespace xnsp = "Tridion.Schema.Metadata.PageMetadata";
XNamespace ns3 = XNamespace.Get("http://www.w3.org/1999/xlink");
XElement addNode= new XElement(xnsp + "add", new XAttribute(XNamespace.Xmlns + "xlink", ns3));
foreach (var value in xxxx)
{
XElement map= new XElement(xnsp+"Map");
//Hard coded - TO DO
XElement isEnabled = new XElement(xnsp+"IsEnabled","No");
XElement path= new XElement(xnsp+"Path", value.Path);
map.Add(isEnabled);
map.Add(path);
routeRoot.Add(map);
}
xMetadata.Add(addNode);
pageData.Metadata = xMetadata.ToString();
client.Update(pageData, new ReadOptions());
One more point, metadata already consists of links to one or two configuration components. I tried adding xlink namespace to metadata root node but it dint solve the problem. Added its namespace to solve the issue but it dint help.
Let me also know if there is a better way to achieve this.