Documentation Center

Example Accessing Page metadata (.NET)

Use the Core Service ItemFields constructor to get the metadata of a Page object in the Content Manager.

// 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);
}