none
This is an unexpected token. The expected token is 'SEMICOLON' while Loading xml file which is read from share point

    Question

  •  

     

    Hi Everybody,

        I am reading xml file from share point which is uploaded already. For reading I used SPFile.Openbinary().....

    the problem is after reading the xml file from share point, i tried to load the xml file in to XMLDocument object

    xmlDoc.LoadXml(gxmlContent);

     But ist is throwing an exception "This is an unexpected token. The expected token is 'SEMICOLON'".

    exception thrown because that xml file contains Special character &....

    I uploaded the following part of xml to share point...

     


    <PartDescription title="SKIL: And Then There Was One…A Great Consolidation Play in a Growing Market at 12x Pro-Forma EPS. Initiating Coverage With a Buy Rating and $10 Price Target."
      synopsis="RESEARCH REPORT WITH TABLES/TEXT ~Suitable for All investment styles * Companies-focused fundamental research (fundamental): outlook for ." abstract="" description="">

     

    But at the time of reading the xml file from share point it will be


    <PartDescription title="SKIL: And Then There Was Oneb &A Great Consolidation Play in a Growing Market at 12x Pro-Forma EPS.  Initiating Coverage With a Buy Rating and $10 Price Target."
                     synopsis="RESEARCH REPORT WITH TABLES/TEXT&#xD;&#xA;~Suitable for All investment styles&#xD;&#xA;&#xD;&#xA;* Companies-focused fundamental research (fundamental):   outlook for .&#xD;&#xA;&#xD;&#xA;" abstract="" description="">

    any one can help me how to read the sharepoint data with out these special character..

     

    Note:

     I think the problem is, i am reading as binary data from share point :( . how to read the XML file from share point?.

    your suggestion is valuable to me..

     

    Thanks

    Mahesh Kannan

     

     

    Tuesday, January 09, 2007 12:29 PM

Answers

  • As far as I can tell, the "..." in "And Then There Was One…A Great Consolidation", is not "dot-dot-dot" but actually a single UNICODE character (probably 0x2026, horizontal ellipse).   Your encoding (probably UTF-8) apparently can't handle it. Try changing it to three dots.
    Tuesday, January 09, 2007 4:50 PM
  • tell me what about other special charactors  like &#xD;&#xA;

    "&" means what follows is an "entity" -- a representation of a character which otherwise has some special meaning.  (e.g. &amp; means "&", &lt; means "<")

    "#" means that it's code value will be given.

    "x" means that code value will be in hexadecimal.

    and ";" means that's the end of the entity.

    SO, "&#xD;" means ascii code 0x0D or 13 (which is an carriage return), and "&#xA;" is code 10, or Line Feed.

    Wednesday, January 10, 2007 3:40 PM
  • Hi James,

       Thanks for your answer, you are correct. Now I got the solution. The problem is with the special character instead of Dot-Dot-Dot. And it is solved by reading the file from Share Point as SPWeb.GetFileAsString() method.

    Thanks

    Mahesh

    Thursday, January 11, 2007 7:02 AM

All replies

  • As far as I can tell, the "..." in "And Then There Was One…A Great Consolidation", is not "dot-dot-dot" but actually a single UNICODE character (probably 0x2026, horizontal ellipse).   Your encoding (probably UTF-8) apparently can't handle it. Try changing it to three dots.
    Tuesday, January 09, 2007 4:50 PM
  • This quite often happens when you edit text in the MS Word. It replace some character combinations on special characters.

    Wednesday, January 10, 2007 2:46 AM
  •  

    Dear James,

            Thanks for your answer

               yes,  Three dots are consolidated thats correct. tell me what about other special charactors  like &#xD;&#xA;,

    actually i think the problem is reading the file from share point. because i am using SpFile.Openbinary(), is there any other way to read xml file from the sharepoint?.

     

    Thanks

    Mahesh

    Wednesday, January 10, 2007 6:51 AM
  • tell me what about other special charactors  like &#xD;&#xA;

    "&" means what follows is an "entity" -- a representation of a character which otherwise has some special meaning.  (e.g. &amp; means "&", &lt; means "<")

    "#" means that it's code value will be given.

    "x" means that code value will be in hexadecimal.

    and ";" means that's the end of the entity.

    SO, "&#xD;" means ascii code 0x0D or 13 (which is an carriage return), and "&#xA;" is code 10, or Line Feed.

    Wednesday, January 10, 2007 3:40 PM
  • Hi James,

       Thanks for your answer, you are correct. Now I got the solution. The problem is with the special character instead of Dot-Dot-Dot. And it is solved by reading the file from Share Point as SPWeb.GetFileAsString() method.

    Thanks

    Mahesh

    Thursday, January 11, 2007 7:02 AM
  • Hello I am having a similar problem. I am trying to read an XML file that is part of a solution, and display the nodes of that XML file in a tree view control in C#.

     

    The error message I get is:

    +        xmlEx    {"'=' is an unexpected token. The expected token is ';'. Line 11, position 117."}    System.Xml.XmlException

     

    The line of the file is:

     

          <MenuItem Name="010" Text="New Buyer T.W.O. Assignment" Link="javascript:gotoPage(1101,'InsertNew=1&Salvage_ID=-1 &Salvage_Type=1&Zip_Code=-1&Specialty=0&Assign_Type=BTTL','009')" Shortcut="BTWO" />

    I have bolded the part referenced in the exception. I have no control over the content of the xml file, I am trying to load it like so:

     

                XmlDocument dom = new XmlDocument();
              
                      dom.Load(myMenuFileLocation.tostring);

     

    and it fails on the load. What should I try to do to rectify this?

     

    Thanks

     

    Mike

    Thursday, September 02, 2010 5:50 PM
  • Well what you have is not XML , if it were XML the ampersands "&" where escaped  as "&amp;". So you need to fix the process creating that file, use XmlWriter or other XML APIs that ensure the XML syntax rules are enforced.
    MVP Data Platform Development My blog
    Thursday, September 02, 2010 6:02 PM
  • Hi MArtin

     

    It is an XML file, the ampersand is a link built into the file, that an application uses for navigation. I did not create this architecture, just trying to work within in. I can not open the document as an XML document, are you saying to open it with a streamreader, and write it as a new XML doc?

     

    Here is more of the file:

    <?xml version="1.0"?>
    <Menu>
      <!--Note: Do not use double quotes inside any attribute of any node.-->
      <MenuItem Name="ASAP" Text="ASAP Menu" Link="" Shortcut="">
        <MenuItem Name="m174" Text="Assignment" Link="" Shortcut="">
          <MenuItem Name="003" Text="New Assignment" Link="javascript:gotoPage(1100,'lstType=Internal&amp;InsertNew=1&amp;Salvage_ID=-1&amp;Salvage_Type=1&amp;Zip_Code=-1&amp;Specialty=0&amp;Salvage_Provider_ID=0&amp;Country_Abbreviation=','003')" Shortcut="ASG"/>
          <MenuItem Name="005" Text="New BidFast Assignment" Link="javascript:gotoPage(1103,'InsertNew=1&amp;Salvage_ID=-1&amp;Salvage_Type=1&amp;Zip_Code=-1&amp;Specialty=0','005')" Shortcut="BF"/>
          <MenuItem Name="008" Text="New Special Recovery Assignment" Link="javascript:gotoPage(1105,'InsertNew=1&amp;Salvage_ID=-1&amp;Salvage_Type=1&amp;Zip_Code=-1&amp;Specialty=4','008')" Shortcut="SR"/>
          <MenuItem Name="51" Text="New BidFast Bid" Link="javascript:gotoPage(1106,'InsertNew=1&amp;Salvage_ID=-1&amp;Salvage_Type=1&amp;Zip_Code=-1&amp;Specialty=0','51')" Shortcut="BFB"/>
          <MenuItem Name="009" Text="New Title Work Only Assignment" Link="javascript:gotoPage(1101,'InsertNew=1&amp;Salvage_ID=-1&amp;Salvage_Type=1&amp;Zip_Code=-1&amp;Specialty=0','009')" Shortcut="TWO"/>
          <MenuItem Name="010" Text="New Buyer T.W.O. Assignment" Link="javascript:gotoPage(1101,'InsertNew=1&Salvage_ID=-1&Salvage_Type=1&Zip_Code=-1&Specialty=0&Assign_Type=BTTL','009')" Shortcut="BTWO" />
          <MenuItem Name="100001" Text="Assignment List" Link="javascript:gotoListSearchNet(1000, 'JInclude=AssignSearchUtils&amp;LastSearchCriteria=1&amp;SearchPageTitle=Assignment List', '100001')" Shortcut="AL"/>
          <MenuItem Name="100002" Text="Assignment List (Internal Status)" Link="javascript:gotoListSearchNet(1000, 'JInclude=AssignSearchUtils&amp;LastSearchCriteria=0&amp;SearchPageTitle=Assignment List (Internal Status)', '100002')" Shortcut="ALI"/>
          <MenuItem Name="100003" Text="Assignment List (Provider)" Link="javascript:gotoListSearchNet(1001, 'JInclude=AssignSearchUtils&amp;SearchPageTitle=Assignment List (Provider)', '100003')" Shortcut="ALP"/>
          <MenuItem Name="100004" Text="Assignment List (VIC)" Link="javascript:gotoListSearchNet(1002, 'JInclude=AssignSearchUtils&amp;SearchPageTitle=Assignment List (VIC)', '100004')" Shortcut="ALV"/>
          <!--<MenuItem Name="100005" Text="Assignment List (Affiliate)" Link="javascript:gotoListSearch(1004, 'JInclude=AssignSearchUtils&amp;SearchPageTitle=Assignment List (Affiliate)', '100005')" Shortcut="ALA"/>-->
          <!--<MenuItem Name="100006" Text="Assignment List (EVA Affiliate)" Link="javascript:gotoListSearch(1017, 'JInclude=AssignSearchUtils&amp;SearchPageTitle=Assignment List (EVA Affiliate) Search', '100006')" Shortcut="AAL"/>-->
          <!--<MenuItem Name="100007" Text="Affiliate Assignment Notification" Link="javascript:gotoPage(1017, '', '100007')" Shortcut="AAN"/>-->
          <MenuItem Name="100008" Text="FastTrack List " Link="javascript:gotoListSearchNet(1003, 'JInclude=AssignSearchUtils&amp;SearchPageTitle=FastTrack List', '100008')" Shortcut="FT"/>
          <MenuItem Name="100009" Text="Specialty Approval Listing" Link="javascript:gotoList(32000, 'lstType=Specialty&amp;Criteria=Specialty_Status_Code=0&amp;_orderBy=Stock_Number', '100009')" Shortcut="SAP"/>
          <MenuItem Name="100010" Text="Network Approval Listing" Link="javascript:gotoPage(1075, '', '100010')" Shortcut="NAP"/>
        </MenuItem>

     

     

    This is what is used for a menu. Each menu item can have child menu items. I am trying to populate a tree view that will show this structure.

    Thursday, September 02, 2010 8:24 PM
  • The XML specification defines what constitutes an XML document, for that the well-formedness rules need to be followed. Your document is not an XML document as it does not follow the well-formedness rules so any XML parser implementing the XML specification is going to reject it as the line

       <MenuItem Name="010" Text="New Buyer T.W.O. Assignment" Link="javascript:gotoPage(1101,'InsertNew=1&Salvage_ID=-1&Salvage_Type=1&Zip_Code=-1&Specialty=0&Assign_Type=BTTL','009')" Shortcut="BTWO" />
    
    does not properly escape the ampersands. The other lines do that so simply ensure, when creating the document, that all ampersands are escaped.

     


    MVP Data Platform Development My blog
    Friday, September 03, 2010 11:53 AM