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,741 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 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