[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1041
  • Last Modified:

SharePoint list XML file not showing Unicode letters correctly

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
mshaji
Asked:
mshaji
  • 4
  • 3
1 Solution
 
Sudhakar PulivarthiCommented:
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
 
Sudhakar PulivarthiCommented:

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
 
mshajiAuthor Commented:
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
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
Sudhakar PulivarthiCommented:

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
 
mshajiAuthor Commented:
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
 
mshajiAuthor Commented:
Dears,

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

Thanks
0
 
mshajiAuthor Commented:
done
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!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now