Accessing Page metadata

To get the metadata of a Page object in the Content Manager, use the ItemFields constructor as illustrated in this example:

// In this example, the Page has two metadata fields: Author and ID
// (referring to some identifier specific to your organization)
static void AccessingPageMetadata(CoreServiceClient client)
{
  const string pageUri = "tcm:2-372-64";
  PageData page = (PageData)client.Read(pageUri, null);

  // load XML metadata into a XDocument
  XDocument doc = XDocument.Parse(page.Metadata);

  // get the namespace of the metadata
  XNamespace ns = doc.Root.Attribute("xmlns").Value;

  // Display Author and ID fields from metadata
  Console.WriteLine("Author = {0}", doc.Root.Element(ns + "Author").Value);
  Console.WriteLine("ID = {0}", doc.Root.Element(ns + "ID").Value);
}