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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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!
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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