1

I'm trying to read the component source tab xml. when i try to get the component.content or Component.Xml Component.LoadXml(Component.xml) it returns an error.

using Tridion.ContentManager.Interop.TDS;
using Tridion.ContentManager.Interop.TDSDefines;
using Tridion.ContentManager;

string applicatiefContentWebdavUrl = "/webdav/04%2E4%20Website%20Functioneel%20Beheer/Building%20Blocks/beheer/dossier/content%20dossier.xml";

            Component Component = (Component)tdse.GetObject(applicatiefContentWebdavUrl, EnumOpenMode.OpenModeEdit, null, XMLReadFilter.XMLReadAll);

            ItemFields fields = new ItemFields(Component.Content, Component.Schema);





Compilation Error 
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS1061: 'Tridion.ContentManager.Interop.TDS.Component' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Tridion.ContentManager.Interop.TDS.Component' could be found (are you missing a using directive or an assembly reference?)



Source Error:



Line 66:             Component Component = (Component)tdse.GetObject(applicatiefContentWebdavUrl, EnumOpenMode.OpenModeEdit, null, XMLReadFilter.XMLReadAll);
Line 67: 
Line 68:             ItemFields fields = new ItemFields(Component.Content, Component.Schema);
Line 69: 
Line 70:             XmlDocument contentxml = new XmlDocument();
  • What is the error you get? – Frank van Puffelen Jul 22 '13 at 11:34
  • 'Tridion.ContentManager.Interop.TDS.Component' does not contain a definition for 'Content' But i dont get that i mean as far as i know i used the right interops and definitions – Roel van Roozendaal Jul 22 '13 at 11:51
  • are you sure the WebDAV URL of the Component you are trying to read is correct? you specify it is starting with a space (%20)? – Bart Koopman Jul 22 '13 at 13:34
  • Yes becouse Component.Schema.Title gives me the correct title. it might be that it starts with %20 becouse i removed some information that is client related :-) – Roel van Roozendaal Jul 22 '13 at 13:45
2

On further inspection of your code, it seems you are trying to mix and match a TOM Component with TOM.NET. This is plainly never going to work. The compiler message is correct. the Component in the TOM hasn't got a .Content property. In those days we worked with the .ItemFields collection.

| improve this answer | |
  • ok so i should use the TOM.NET only then ;p assuming this would not give me any problems in a 2009 powertool. – Roel van Roozendaal Jul 22 '13 at 14:02
  • @RoelVanRoozendaal you cannot use TOM.NET outside of Templating or the Event System, so in 2009 you can only use ASP with TOM, or ASP.NET with TOM Interops – Bart Koopman Jul 22 '13 at 15:59
  • @RoelVanRoozendaal so remove the statement using Tridion.ContentManager; so you only have availibility of the TOM Interops and won't mix in TOM.NET – Bart Koopman Jul 22 '13 at 16:06
  • Yhe thats why i used the interrupt since it's outside templating, the answer confused me a bit. i will remove the Tridion.ContentManager using. but won’t help me in my quest to solve my problem. since Dominic already mentioned that component.content is not part of the interrupt. still i think there must be a rather simple solution to get around it. all i want to do is get the source of a component so i can easily add and remove items from it (it contains 500+ repeatable fields) else i would have used the object it self. but this will be to slow. – Roel van Roozendaal Jul 23 '13 at 5:46
2

Since i can’t use the Component.Content or .xml i'm going to get it in the following way. Thanks all for the quick reply's

Component objComponent = (Component)tdse.GetObject(applicatiefContentWebdavUrl, EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadAll);

    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.LoadXml(objComponent.GetXML(XMLReadFilter.XMLReadDataContent));
    //xmlDoc.Save("d:\\temp\\roel.xml");

    XmlNode nodeList = xmlDoc.SelectSingleNode("//*[local-name()='Content']/*");

    foreach (XmlNode nodes in nodeList)
    {
        Response.Write("TEST: " + node.InnerXml);
    }
| improve this answer | |
  • This is the correct way, now you are using Tridion.ContentManager.Interop.TDS.Component – Bart Koopman Jul 23 '13 at 8:09
1

I think the compiler is confused by the fact you have called your Component "Component". It's trying to dereference the Content property on the type rather than the instance. Writing similar code, I'd probably use lower case (or camel case) for the instance name:

Component component = (Component)tdse.GetObject(...)
| improve this answer | |
  • No Luck there, i agree it's better to use the lower case. but still the same error :-( – Roel van Roozendaal Jul 22 '13 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.