Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:43:57+00:00 2026-06-08T08:43:57+00:00

I call a method to get my pages [see GetPages(String xmlFullFilePath)]. The FromXElement method

  • 0

I call a method to get my pages [see GetPages(String xmlFullFilePath)]. The FromXElement method is supposed to deserialise the LitePropertyData elements to strongly type LitePropertyData objects. Instead it fails on the following line:

return (T)xmlSerializer.Deserialize(memoryStream);

and gives the following error:

<LitePropertyData xmlns=''> was not expected.

What am I doing wrong? I have included the methods that I call and the xml data:

    public static T FromXElement<T>(this XElement xElement)
    {
        using (var memoryStream = new MemoryStream(Encoding.ASCII.GetBytes(xElement.ToString())))
        {
            var xmlSerializer = new XmlSerializer(typeof(T));
            return (T)xmlSerializer.Deserialize(memoryStream);
        }
    }


public static List<LitePageData> GetPages(String xmlFullFilePath)
    {
        XDocument document = XDocument.Load(xmlFullFilePath);

        List<LitePageData> results = (from record in document.Descendants("row")
                                      select new LitePageData
                                      {
                                          Guid = IsValid(record, "Guid") ?
                                            record.Element("Guid").Value :
                                            null,
                                          ParentID = IsValid(record, "ParentID") ?
                                                Convert.ToInt32(record.Element("ParentID").Value) :
                                                (Int32?)null,
                                          Created = Convert.ToDateTime(record.Element("Created").Value),
                                          Changed = Convert.ToDateTime(record.Element("Changed").Value),
                                          Name = record.Element("Name").Value,
                                          ID = Convert.ToInt32(record.Element("ID").Value),
                                          LitePageTypeID = IsValid(record, "ParentID") ?
                                                Convert.ToInt32(record.Element("ParentID").Value) :
                                                (Int32?)null,
                                          Html = record.Element("Html").Value,
                                          FriendlyName = record.Element("FriendlyName").Value,
                                          Properties = record.Element("Properties") != null ? record.Element("Properties").Element("LitePropertyData").FromXElement<List<LitePropertyData>>() :
                                            new List<LitePropertyData>()
                                      }).ToList();

        return results;
    }

Here is the xml:

<?xml version="1.0" encoding="utf-8"?> <root>   <rows>
<row>
  <ID>1</ID>
  <ImageUrl></ImageUrl>
  <Html>Home page</Html>
  <Created>01-01-2012</Created>
  <Changed>01-01-2012</Changed>
  <Name>Home page</Name>
  <FriendlyName>home-page</FriendlyName>
</row>
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Guid>edeaf468-f490-4271-bf4d-be145bc6a1fd</Guid>
  <ID>8</ID>
  <Name>Unused</Name>
  <ParentID>1</ParentID>
  <Created>2006-03-25T10:57:17</Created>
  <Changed>2012-07-17T12:24:30.0984747+01:00</Changed>
  <ChangedBy />
  <LitePageTypeID xsi:nil="true" />
  <Html>
    What is the purpose of this option? This option checks the current document for accessibility issues. It uses Bobby to provide details of whether the current web page conforms to W3C's WCAG criteria for web content accessibility.


    Issues with Bobby and Cynthia

    Bobby and Cynthia are free services that supposedly allow a user to expose web page accessibility barriers. It is something of a guide but perhaps a blunt instrument. I tested a few of the webpages that I have designed. Sure enough, my pages fall short and for good reason. I am not about to claim that Bobby and Cynthia are useless. Although it is useful and commendable tool, it project appears to be overly ambitious. Nevertheless, let me explain my issues with Bobby and Cynthia:

    First, certain W3C standards for designing web documents are often too strict and unworkable. For instance, in some versions W3C standards for HTML, certain tags should not include a particular attribute, whereas in others they are requisite if the document is to be ???well-formed???. The standard that a designer chooses is determined usually by the requirements specification document. This specifies which browsers and versions of those browsers that the web page is expected to correctly display. Forcing a hypertext document to conform strictly to a specific W3C standard for HTML is often no simple task. In the worst case, it cannot conform without losing some aesthetics or accessibility functionality.

    Second, the case of HTML documents is not an isolated case. Standards for XML, XSL, JavaScript, VBScript, are analogous. Therefore, you might imagine the problems when you begin to combine these languages and formats in an HTML document.

    Third, there is always more than one way to skin a cat. For example, Bobby and Cynthia may flag those IMG tags that do not contain a TITLE attribute. There might be good reason that a web developer chooses not to include the title attribute. The title attribute has a limited numbers of characters and does not support carriage returns. This is a major defect in the design of this tag. In fact, before the TITLE attribute was supported, there was the ALT attribute. Most browsers support both, yet they both perform a similar function. However, both attributes share the same deficiencies. In practice, there are instances where neither attribute would be used. Instead, for example, the developer would write some JavaScript or VBScript to circumvent these deficiencies. The concern is that Bobby and Cynthia would not notice this because it does not ???understand??? what the JavaScript does.
  </Html>
  <FriendlyName>unused</FriendlyName>
  <IsDeleted>false</IsDeleted>
  <Properties>
    <LitePropertyData>
      <Description>Image for the page</Description>
      <DisplayEditUI>true</DisplayEditUI>
      <OwnerTab>1</OwnerTab>
      <DisplayName>Image Url</DisplayName>
      <FieldOrder>1</FieldOrder>
      <IsRequired>false</IsRequired>
      <Name>ImageUrl</Name>
      <IsModified>false</IsModified>
      <ParentPageID>3</ParentPageID>
      <Type>String</Type>
      <Value xsi:type="xsd:string">smarter.jpg</Value>
    </LitePropertyData>
    <LitePropertyData>
      <Description>WebItemApplicationEnum</Description>
      <DisplayEditUI>true</DisplayEditUI>
      <OwnerTab>1</OwnerTab>
      <DisplayName>WebItemApplicationEnum</DisplayName>
      <FieldOrder>1</FieldOrder>
      <IsRequired>false</IsRequired>
      <Name>WebItemApplicationEnum</Name>
      <IsModified>false</IsModified>
      <ParentPageID>3</ParentPageID>
      <Type>Number</Type>
      <Value xsi:type="xsd:string">1</Value>
    </LitePropertyData>
  </Properties>
  <Seo>
    <Author>Phil Carney</Author>
    <Classification />
    <Copyright>Carnotaurus</Copyright>
    <Description>
      What is the purpose of this option? This option checks the current document for accessibility issues. It uses Bobby to provide details of whether the current web page conforms to W3C's WCAG criteria for web content accessibility.


      Issues with Bobby and Cynthia

      Bobby and Cynthia are free services that supposedly allow a user to expose web page accessibility barriers. It is something of a guide but perhaps a blunt instrument. I tested a few of the webpages that I have designed. Sure enough, my pages fall short and for good reason. I am not about to claim that Bobby and Cynthia are useless. Although it is useful and commendable tool, it project appears to be overly ambitious. Nevertheless, let me explain my issues with Bobby and Cynthia:

      First, certain W3C standards for designing web documents are often too strict and unworkable. For instance, in some versions W3C standards for HTML, certain tags should not include a particular attribute, whereas in others they are requisite if the document is to be ???well-formed???. The standard that a designer chooses is determined usually by the requirements specification document. This specifies which browsers and versions of those browsers that the web page is expected to correctly display. Forcing a hypertext document to conform strictly to a specific W3C standard for HTML is often no simple task. In the worst case, it cannot conform without losing some aesthetics or accessibility functionality.

      Second, the case of HTML documents is not an isolated case. Standards for XML, XSL, JavaScript, VBScript, are analogous. Therefore, you might imagine the problems when you begin to combine these languages and formats in an HTML document.

      Third, there is always more than one way to skin a cat. For example, Bobby and Cynthia may flag those IMG tags that do not contain a TITLE attribute. There might be good reason that a web developer chooses not to include the title attribute. The title attribute has a limited numbers of characters and does not support carriage returns. This is a major defect in the design of this tag. In fact, before the TITLE attribute was supported, there was the ALT attribute. Most browsers support both, yet they both perform a similar function. However, both attributes share the same deficiencies. In practice, there are instances where neither attribute would be used. Instead, for example, the developer would write some JavaScript or VBScript to circumvent these deficiencies. The concern is that Bobby and Cynthia would not notice this because it does not ???understand??? what the JavaScript does.
    </Description>
    <Keywords>unused</Keywords>
    <Title>unused</Title>
  </Seo>
</row>   </rows> </root>

EDIT

Here are my entities:

public class LitePropertyData
{

    public virtual string Description { get; set; }
    public virtual bool DisplayEditUI { get; set; }
    public int OwnerTab { get; set; }
    public virtual string DisplayName { get; set; }
    public int FieldOrder { get; set; }
    public bool IsRequired { get; set; }

    public string Name { get; set; }
    public virtual bool IsModified { get; set; }
    public virtual int ParentPageID { get; set; }
    public LiteDataType Type { get; set; }
    public  object Value { get; set; }

}

[Serializable]
public class LitePageData
{
    public String Guid { get; set; }
    public Int32 ID { get; set; }
    public String Name { get; set; }
    public Int32? ParentID { get; set; }
    public DateTime Created { get; set; }
    public String CreatedBy { get; set; }
    public DateTime Changed { get; set; }
    public String ChangedBy { get; set; }
    public Int32? LitePageTypeID { get; set; }
    public String Html { get; set; }
    public String FriendlyName { get; set; }
    public Boolean IsDeleted { get; set; }
    public List<LitePropertyData> Properties { get; set; }
    public LiteSeoPageData Seo { get; set; }

    /// <summary>
    /// Saves the specified XML full file path.
    /// </summary>
    /// <param name="xmlFullFilePath">The XML full file path.</param>
    public void Save(String xmlFullFilePath)
    {
        XDocument doc = XDocument.Load(xmlFullFilePath);

        XElement demoNode = this.ToXElement<LitePageData>();

        demoNode.Name = "row";

        doc.Descendants("rows").Single().Add(demoNode);

        doc.Save(xmlFullFilePath);
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:43:59+00:00Added an answer on June 8, 2026 at 8:43 am

    I refactored the logic to obtain the Properties into a GetProperties method. Then commented out the original code to populate Properties within the GetPages method, before calling the new method:

        public static List<LitePropertyData> GetProperties(XElement record)
        {
            if (record.Element("Properties") == null) return new List<LitePropertyData>();
            if (record.Descendants("Properties")== null) return new List<LitePropertyData>();
            if (record.Descendants("Properties").Descendants("LitePropertyData") == null) return new List<LitePropertyData>();
    
            List<LitePropertyData> properties =
            (from property in record.Descendants("Properties").Descendants("LitePropertyData")
             select new LitePropertyData
             {
                 Description = property.Element("Description").Value,
                 DisplayEditUI = property.Element("DisplayEditUI").Value.ToBoolean(),
                 DisplayName = property.Element("DisplayName").Value,
                 FieldOrder = property.Element("FieldOrder").Value.ToInt32(),
                 IsModified = property.Element("IsModified").Value.ToBoolean(),
                 IsRequired = property.Element("IsRequired").Value.ToBoolean(),
                 Name = property.Element("Name").Value,
                 OwnerTab = property.Element("OwnerTab").Value.ToInt32(),
                 ParentPageID = property.Element("ParentPageID").Value.ToInt32(),
                 Type = (LiteDataType)property.Element("Type").Value.ToInt32(),
                 Value = property.Element("Value").Value,
             }).ToList();
    
            return properties;
        }
    
    
        /// <summary>
        /// Gets the pages.
        /// </summary>
        /// <param name="xmlFullFilePath">The XML full file path.</param>
        /// <returns></returns>
        public static List<LitePageData> GetPages(String xmlFullFilePath)
        {
            XDocument document = XDocument.Load(xmlFullFilePath);
    
            List<LitePageData> results = (from record in document.Descendants("row")
                                          select new LitePageData
                                          {
                                              Guid = IsValid(record, "Guid") ?
                                                record.Element("Guid").Value :
                                                null,
                                              ParentID = IsValid(record, "ParentID") ?
                                                    Convert.ToInt32(record.Element("ParentID").Value) :
                                                    (Int32?)null,
                                              Created = Convert.ToDateTime(record.Element("Created").Value),
                                              Changed = Convert.ToDateTime(record.Element("Changed").Value),
                                              Name = record.Element("Name").Value,
                                              ID = Convert.ToInt32(record.Element("ID").Value),
                                              LitePageTypeID = IsValid(record, "ParentID") ?
                                                    Convert.ToInt32(record.Element("ParentID").Value) :
                                                    (Int32?)null,
                                              Html = record.Element("Html").Value,
                                              FriendlyName = record.Element("FriendlyName").Value,
                                              Properties = GetProperties(record),
                                              //record.Element("Properties") != null ? record.Element("Properties").FromXElement<List<LitePropertyData>>() :
                                              //  new List<LitePropertyData>()
                                          }).ToList();
    
            return results;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method called Get and a call back method called X written
Does anyone know why I get undefined method `my_method' for #<MyController:0x1043a7410> when I call
Whenever I call my logger in a method, e.g. _logger.Debug(Connecting to database...); I get
When I use call_user_func on a non-static method in PHP 5.2 I get a
How to call method of my Service each time Activity unbinds it? It's desirable
I'm trying to call method from .jar But when I want to declare array
I am getting: Can't call method test without a package or object reference at
I have a requirement: I want to call method every day at any particular
I have 2 classes 'Main' and 'FOR'. From 'Main' I will call method 'display'
I have a form: <form name=emailform id=emailform onsubmit=emailSubmit() method=post><div> <input type=text id=email name=email value=>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.