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,672 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
  • 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now