Solved

SharePoint list XML file not showing Unicode letters correctly

Posted on 2011-09-28
7
941 Views
Last Modified: 2012-05-12
Dears,

I need to read Unicode letters of this XML data:

- <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_NameOrTitle" rs:name="Name" rs:number="1">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
- <s:AttributeType name="ows_Title" rs:name="Title" rs:number="2">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
- <s:AttributeType name="ows_Picture_Description" rs:name="Picture_Description" rs:number="3">
  <s:datatype dt:type="string" dt:maxLength="1073741823" />
  </s:AttributeType>
- <s:AttributeType name="ows_RequiredField" rs:name="Required Field" rs:number="4">
  <s:datatype dt:type="string" dt:maxLength="512" />
  </s:AttributeType>
  </s:ElementType>
  </s:Schema>
- <rs:data>
  <z:row ows_NameOrTitle="1.jpg" ows_Title="First Image of water here" ows_Picture_Description="The World Bank is a vital source. ¿¿¿¿ ¿¿¿¿¿" ows_RequiredField="English/it/SilverLightLibrary/1.jpg" />
  <z:row ows_NameOrTitle="10.jpg" ows_Title="10th Image Title" ows_Picture_Description=" the International Development. ¿¿¿¿¿¿¿ ¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿." ows_RequiredField="English/it/SilverLightLibrary/10.jpg" />
  </rs:data>
  </xml>


In this XML i have Arabic characters but while reading this XML the Arabic letters are coming in garbage mode. Any Idea. I used the below code to read it by C#.

            string xml = webClient.DownloadString("http://localhost/it/_vti_bin/owssvr.dll?Cmd=Display&List={A4F6BEA6-2830-431B-B9A8-90200970B00E}&XMLDATA=TRUE");
            context.Cache.Insert("movieXml", xml, null, DateTime.UtcNow.AddDays(1), TimeSpan.FromSeconds(0));
            context.Response.ContentType = "text/xml";
            context.Response.Write(context.Cache["movieXml"].ToString());



           XDocument xDoc = XDocument.Parse(e.Result);

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


Here when I debug this code the variable xDoc  shows all XML data but the Arabic letters are in garbage. So how i can convert it into Unicode.

Remember that I cannot change anything in XML file because its the XML version of SharePoint list.

Any help?





- <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_NameOrTitle" rs:name="Name" rs:number="1">
  <s:datatype dt:type="string" dt:maxLength="512" /> 
  </s:AttributeType>
- <s:AttributeType name="ows_Title" rs:name="Title" rs:number="2">
  <s:datatype dt:type="string" dt:maxLength="512" /> 
  </s:AttributeType>
- <s:AttributeType name="ows_Picture_Description" rs:name="Picture_Description" rs:number="3">
  <s:datatype dt:type="string" dt:maxLength="1073741823" /> 
  </s:AttributeType>
- <s:AttributeType name="ows_RequiredField" rs:name="Required Field" rs:number="4">
  <s:datatype dt:type="string" dt:maxLength="512" /> 
  </s:AttributeType>
  </s:ElementType>
  </s:Schema>
- <rs:data>
  <z:row ows_NameOrTitle="1.jpg" ows_Title="First Image of water here" ows_Picture_Description="The World Bank is a vital source. ¿¿¿¿ ¿¿¿¿¿" ows_RequiredField="English/it/SilverLightLibrary/1.jpg" /> 
  <z:row ows_NameOrTitle="10.jpg" ows_Title="10th Image Title" ows_Picture_Description=" the International Development. ¿¿¿¿¿¿¿ ¿¿¿¿ ¿¿¿¿¿¿ ¿¿¿¿¿¿¿¿." ows_RequiredField="English/it/SilverLightLibrary/10.jpg" /> 
  </rs:data>
  </xml>



            string xml = webClient.DownloadString("http://localhost/it/_vti_bin/owssvr.dll?Cmd=Display&List={A4F6BEA6-2830-431B-B9A8-90200970B00E}&XMLDATA=TRUE");
            context.Cache.Insert("movieXml", xml, null, DateTime.UtcNow.AddDays(1), TimeSpan.FromSeconds(0));
            context.Response.ContentType = "text/xml";
            context.Response.Write(context.Cache["movieXml"].ToString());



           XDocument xDoc = XDocument.Parse(e.Result);

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

Open in new window

0
Comment
Question by:mshaji
  • 4
  • 3
7 Comments
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36717448
Hi

http://stackoverflow.com/questions/4568811/loading-xml-with-encoding-utf-16-using-xdocument

Provide the <?xml version="1.0" encoding="utf-16"?> encoding information in the xml data and pass it to XDocument.
Check out what is the encoding type for arabic chars support like utf-8, utf-16, utf-32
0
 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36717471

Check it out. To first read the chars properly from the source as shown here:
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_25334916.html
0
 

Author Comment

by:mshaji
ID: 36815148
many thanks for the replay

I am not able to alter the XML file because its the XML view of my SharePoint list. So by default SharePoint itself created this XML. So i cannot add/ alter the <?xml version="1.0" encoding="utf-16"?>.

I want to just read the data  from this XML and while reading the Arabic letters are coming in garbage. Is there any way to encode the XDocument or any other way to change the SharePoint list XML view.

Thank you
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:Sudhakar Pulivarthi
ID: 36815174

Try this:

It looks like the file you are trying to read is not encoded as Unicode. You can replicate the behavior by trying to open a file encoded as ANSI with the encoding in the XML file specified as utf-16.
If you can't ensure that the file is encoded properly, then you can read the file into a stream (letting the StreamReader detect the encoding) and then create the XDocument:

using (StreamReader sr = new StreamReader(path, true))
{
    XDocument xdoc = XDocument.Load(sr);
}

Source: http://stackoverflow.com/questions/4568811/loading-xml-with-encoding-utf-16-using-xdocument


0
 

Author Comment

by:mshaji
ID: 36896406
Dears,

It solved now the Unicode problem. Arabic letters are coming correctly but in a reverse order. So i used the property FlowDirection like FlowDirection="RightToLeft" its throwing an error that: The property 'FlowDirection' does not exist on the type 'TextBlock' in the XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.      Do have any idea?.

See my XAML code here:
<UserControl xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"  x:Class="CoverFlowClient.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:app="clr-namespace:CoverFlowClient"
             xmlns:c="clr-namespace:ControlLibrary;assembly=ControlLibrary"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" >
    <UserControl.Resources>
        <app:DateFormatter x:Key="DateConverter"/>
    </UserControl.Resources >


 <Border x:Name="detailsGrid" DataContext="{Binding SelectedItem, ElementName=flowControl}" Visibility="Collapsed"  Width="680" Grid.Row="1" Margin="5" Padding="4" BorderBrush="Black" BorderThickness="0" CornerRadius="0">
                <Grid >
                    <ScrollViewer  VerticalScrollBarVisibility="Auto" Grid.Row="1" Grid.ColumnSpan="4"  Margin="0" >
                        
                        <TextBlock Text="Salam - ¿¿¿¿" TextWrapping="Wrap" FlowDirection="RightToLeft" Foreground="DarkBlue" ></TextBlock>

                    </ScrollViewer>

                </Grid>
            </Border>


In the above code giving the error:  The property 'FlowDirection' does not exist on the type 'TextBlock' in the XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

Open in new window

0
 

Accepted Solution

by:
mshaji earned 0 total points
ID: 36901882
Dears,

i solved it by changing the version of SilverLight from 3 to 4

Thanks
0
 

Author Closing Comment

by:mshaji
ID: 36929598
done
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
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.
This video discusses moving either the default database or any database to a new volume.

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

8 Experts available now in Live!

Get 1:1 Help Now