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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SharePoint 2013 List with Ratings 6 34
Receiving a string from a WebService Push 21 36
Variable Event ? 3 22
C# Comparing String Arrays. 5 20
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

23 Experts available now in Live!

Get 1:1 Help Now