Solved

Reading XML File showing an error:  The ':' character, hexadecimal value 0x3A, cannot be included in a name.

Posted on 2011-09-27
3
1,823 Views
Last Modified: 2012-05-12
Dears,

I have a SharePoint picture library list and i got the corresponding XML file which contains the data like

- <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
- <s:Schema id="RowsetSchema">
- <s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30">
- <s:AttributeType name="ows_SelectedFlag" rs:name="Selection Checkbox" rs:number="1">
  <s:datatype dt:type="ui1" dt:maxLength="4" />
  </s:AttributeType>
- <s:AttributeType name="ows_DocIcon" rs:name="Type" rs:number="2">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
- <s:AttributeType name="ows_NameOrTitle" rs:name="Name" rs:number="3">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
- <s:AttributeType name="ows_ImageSize" rs:name="Picture Size" rs:number="4">
  <s:datatype dt:type="i4" dt:maxLength="4" />
  </s:AttributeType>
- <s:AttributeType name="ows_FileSizeDisplay" rs:name="File Size" rs:number="5">
  <s:datatype dt:type="i4" dt:maxLength="4" />
  </s:AttributeType>
- <s:AttributeType name="ows_RequiredField" rs:name="Required Field" rs:number="6">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
- <s:AttributeType name="ows_Details" rs:name="Details" rs:number="7">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
  </s:ElementType>
  </s:Schema>
- <rs:data>
  <z:row ows_SelectedFlag="0" ows_DocIcon="jpg" ows_NameOrTitle="Desert.jpg" ows_ImageSize="1024" ows_FileSizeDisplay="845941" ows_RequiredField="English/it/SilverLightLibrary/Desert.jpg" ows_Details="Details here" />
  <z:row ows_SelectedFlag="0" ows_DocIcon="jpg" ows_NameOrTitle="SD.jpg" ows_ImageSize="754" ows_FileSizeDisplay="122248" ows_RequiredField="English/it/SilverLightLibrary/SD.jpg" ows_Details="SD Details here" />
  </rs:data>
  </xml>

Here I wanted to get the Name of Image,  Details of image by using C# code, for that I wrote the code inside a foreach loop to fetch all data from this XML


 void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            XDocument xDoc = XDocument.Parse(e.Result);
           
            foreach (XElement xMovieInfo in xDoc.Descendants("rs:data"))
            {
                try
                {
                    MovieTrailer trailer = new MovieTrailer(xMovieInfo);
                    trailers.Add(trailer);
                }
                catch { }
            }
        }

Here this code throwing an error : The ':' character, hexadecimal value 0x3A, cannot be included in a name.


My aim is how to get the image name, image path and image details from the above XML file by using C# code.


Thanks in advance
Regards
0
Comment
Question by:mshaji
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:yogsoft
ID: 36708349
Fix:

 
foreach (XElement xMovieInfo in xDoc.Descendants(XName.Get("data","urn:schemas-microsoft-com:rowset")))
            {
                try
                {
                    MovieTrailer trailer = new MovieTrailer(xMovieInfo);
                    trailers.Add(trailer);
                }
                catch { }
            }

Open in new window

0
 
LVL 2

Accepted Solution

by:
yogsoft earned 500 total points
ID: 36708383
Fix with reading attributes:


 
foreach (XElement xMovieInfo in xDoc.Descendants(XName.Get("data","urn:schemas-microsoft-com:rowset")).Descendants())
            {
                try
                {
                    //MovieTrailer trailer = new MovieTrailer(xMovieInfo);
                    //trailers.Add(trailer);
                    Console.WriteLine((string)xMovieInfo.Attribute("ows_NameOrTitle"));
                    Console.WriteLine((string)xMovieInfo.Attribute("ows_Details"));
                }
                catch { }
            }

Open in new window

0
 

Author Closing Comment

by:mshaji
ID: 36708790
Dear,
I really appreciate and thanks for the kind  help. Your modified code solved my issue for ever.

Thank  you so much dear.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question