LINQ and XML for compact framework

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • luowan@gmail.com

    LINQ and XML for compact framework

    Hi

    I am currently building an application on .NetCF 3.5 in C#. The
    application needs to process xml files. I am thinking about using LINQ
    to process XML. I wrote a piece of code to modify the specified
    element's value.


    XmlReaderSettin gs settings = new
    XmlReaderSettin gs();
    settings.Confor manceLevel =
    ConformanceLeve l.Fragment;
    settings.Ignore Whitespace = true;
    settings.Ignore Comments = true;
    XmlReader reader = XmlReader.Creat e(inboxPath,
    settings);

    XElement root = XElement.Load(r eader);
    IEnumerable<XEl ementmsgs = from el in
    root.Descendant s("Message")
    where el.Element("Mes sageID").Value ==
    MsgID
    select el;

    foreach (XElement el in msgs)
    {

    el.Element("Mes sageStaus").Set Value(newStatus .ToString());
    }
    root.Save(inbox Path);

    Here is the error message that I received :

    msgs.System.Col lections.Generi c.IEnumerator<T Source>.Current 'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
    does not contain a definition for 'System' and no extension method
    'System' accepting a first argument of type
    'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
    could be found (are you missing a using directive or an assembly
    reference?)

    Could someone please explain to me why I get such error message? By
    the way I have refference all the necessary dlls. (System.linq;
    System.xml.linq )

    Is it because I am using compact framework? I've tested this code on
    a normal framework. It is working fine.



  • Jon Skeet [C# MVP]

    #2
    Re: LINQ and XML for compact framework

    <luowan@gmail.c omwrote:

    <snip>
    Is it because I am using compact framework? I've tested this code on
    a normal framework. It is working fine.
    That's very strange indeed - what line does the error message point at?

    Could you post a short but complete program which demonstrates the
    problem?

    See http://www.pobox.com/~skeet/csharp/complete.html for details of
    what I mean by that.

    --
    Jon Skeet - <skeet@pobox.co m>
    Web site: http://www.pobox.com/~skeet
    Blog: http://www.msmvps.com/jon.skeet
    C# in Depth: http://csharpindepth.com

    Comment

    • Wan

      #3
      Re: LINQ and XML for compact framework

      On Apr 30, 7:52 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
       <luo...@gmail.c omwrote:
      >
      <snip>
      >
      Is it because I am using compact framework?  I've tested this code on
      a normal framework.  It is working fine.
      >
      That's very strange indeed - what line does the error message point at?
      >
      Could you post a short but complete program which demonstrates the
      problem?
      >
      Seehttp://www.pobox.com/~skeet/csharp/complete.htmlfo r details of
      what I mean by that.
      >
      --
      Jon Skeet - <sk...@pobox.co m>
      Web site:http://www.pobox.com/~skeet 
      Blog:http://www.msmvps.com/jon.skeet
      C# in Depth:http://csharpindepth.com
      Actually it is not error, my program is still running. However, if I
      place a break point at
      IEnumerable<XEl ementmsgs = from el in
      root.Descendant s("Message")
      where el.Element("Mes sageID").Value ==
      MsgID
      select el;





      After the statement is excuted, if I look up 'msgs' 's value, I will
      get such error message.

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: LINQ and XML for compact framework

        Wan <luowan@gmail.c omwrote:
        Actually it is not error, my program is still running. However, if I
        place a break point at
        IEnumerable<XEl ementmsgs = from el in
        root.Descendant s("Message")
        where el.Element("Mes sageID").Value ==
        MsgID
        select el;
        >
        >
        After the statement is excuted, if I look up 'msgs' 's value, I will
        get such error message.
        In that case it sounds like a debugger problem rather than anything
        else.

        --
        Jon Skeet - <skeet@pobox.co m>
        Web site: http://www.pobox.com/~skeet
        Blog: http://www.msmvps.com/jon.skeet
        C# in Depth: http://csharpindepth.com

        Comment

        • Wan

          #5
          Re: LINQ and XML for compact framework

          On Apr 30, 9:46 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
          Wan <luo...@gmail.c omwrote:
          Actually it is not error, my program is still running.  However, if I
          place a break point at
          IEnumerable<XEl ementmsgs = from el in
          root.Descendant s("Message")
                                         where el.Element("Mes sageID").Value ==
          MsgID
                                         select el;
          >
          After the statement is excuted, if I look up 'msgs' 's value, I will
          get such error message.
          >
          In that case it sounds like a debugger problem rather than anything
          else.
          >
          --
          Jon Skeet - <sk...@pobox.co m>
          Web site:http://www.pobox.com/~skeet 
          Blog:http://www.msmvps.com/jon.skeet
          C# in Depth:http://csharpindepth.com
          I've tested on two PCs, both the same.
          Can some one post a tested working code of query the XML by using LINQ
          with compact framework?

          Comment

          • Jon Skeet [C# MVP]

            #6
            Re: LINQ and XML for compact framework

            Wan <luowan@gmail.c omwrote:
            I've tested on two PCs, both the same.
            Can some one post a tested working code of query the XML by using LINQ
            with compact framework?
            Well hang on - you've posted an error which you look in the debugger.
            You've said the program is still running. What's it doing that you
            don't expect it to?

            Could you post a short but complete program which demonstrates the
            problem?

            See http://www.pobox.com/~skeet/csharp/complete.html for details of
            what I mean by that.

            --
            Jon Skeet - <skeet@pobox.co m>
            Web site: http://www.pobox.com/~skeet
            Blog: http://www.msmvps.com/jon.skeet
            C# in Depth: http://csharpindepth.com

            Comment

            • Wan

              #7
              Re: LINQ and XML for compact framework

              On Apr 30, 10:14 pm, Jon Skeet [C# MVP] <sk...@pobox.co mwrote:
              Wan <luo...@gmail.c omwrote:
              I've tested on two PCs, both the same.
              Can some one post a tested working code of query the XML by using LINQ
              with compact framework?
              >
              Well hang on - you've posted an error which you look in the debugger.
              You've said the program is still running. What's it doing that you
              don't expect it to?
              >
              Could you post a short but complete program which demonstrates the
              problem?
              >
              Seehttp://www.pobox.com/~skeet/csharp/complete.htmlfo r details of
              what I mean by that.
              >
              --
              Jon Skeet - <sk...@pobox.co m>
              Web site:http://www.pobox.com/~skeet 
              Blog:http://www.msmvps.com/jon.skeet
              C# in Depth:http://csharpindepth.com
              Here is the full sample code. with the XML sample.




              Code Snippetusing System;

              using System.Linq;

              using System.Collecti ons.Generic;

              using System.Componen tModel;

              using System.Data;

              using System.Drawing;

              using System.Text;

              using System.Windows. Forms;

              using System.Xml.Linq ;

              using System.Xml;

              namespace xmlCFtest

              {

              public partial class Form1 : Form

              {

              public Form1()

              {

              InitializeCompo nent();

              updateMsg("1472 2", 5);

              }

              private void updateMsg(strin g MsgID, int newStatus)

              {

              try

              {

              XmlReaderSettin gs settings = new XmlReaderSettin gs();

              settings.Confor manceLevel = ConformanceLeve l.Fragment;

              settings.Ignore Whitespace = true;

              settings.Ignore Comments = true;

              XmlReader reader = XmlReader.Creat e(@"Program Files\messagecl ient\XML
              \Inbox.xml", settings);

              XElement root = XElement.Load(r eader);

              IEnumerable<XEl ementmsgs = from el in root.Descendant s("Message")

              where el.Element("Mes sageID").Value == MsgID

              select el;

              foreach (XElement el in msgs)

              {

              el.Element("Mes sageStaus").Set Value(newStatus .ToString());

              }

              root.Save(@"Pro gram Files\messagecl ient\XML\Inbox. xml");

              }

              catch (Exception e) { }

              }

              }

              }











              XML Sample:




              Code Snippet<?xml version="1.0"?>
              <ArrayOfMessa ge xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
              xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
              <Message>
              <IMEI xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">35 340401169569600 </IMEI>
              <MessageText xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">hi </MessageText>
              <MessageID xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">14 722</MessageID>
              <UserID xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">12 984</UserID>
              <SenderName xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">Ha rdCode Test </SenderName>
              <TimeStamp xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">20 08-04-29T16:26:36.097 </TimeStamp>
              <MessageStaus xmlns="http://FleetMatics.com/WCFMessageServi ce/
              Message.xsd">3</MessageStaus>
              </Message>

              </ArrayOfMessage>


              Hi Jon
              When I said the program was running, I mean the code was compiled.
              However, the code does not do the job. The project I created was
              based on Windows Mobile 6 SDK and Compact Framework 3.5.

              Regards,
              Wan

              Comment

              • Jon Skeet [C# MVP]

                #8
                Re: LINQ and XML for compact framework

                On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
                Here is the full sample code. with the XML sample.
                Well, it's not exactly a full sample - it doesn't contain a Main
                method, for instance. It's not even a complete class - where's the
                implementation of InitializeCompo nent?
                Hint: console apps are generally a lot shorter.

                See http://pobox.com/~skeet/csharp/incomplete.html
                When I said the program was running, I mean the code was compiled.
                However, the code does not do the job. The project I created was
                based on Windows Mobile 6 SDK and Compact Framework 3.5.
                When you say "the code does not do the job" what exactly do you mean?
                What does it do, and what do you want it to do?

                Jon

                Comment

                • Wan

                  #9
                  Re: LINQ and XML for compact framework

                  On May 1, 11:44 am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
                  On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
                  >
                  Here is the full sample code. with the XML sample.
                  >
                  Well, it's not exactly a full sample - it doesn't contain a Main
                  method, for instance. It's not even a complete class - where's the
                  implementation of InitializeCompo nent?
                  Hint: console apps are generally a lot shorter.
                  >
                  Seehttp://pobox.com/~skeet/csharp/incomplete.html
                  >
                  When I said the program was running, I mean the code was compiled.
                  However, the code does not do the job.  The project I created was
                  based on Windows Mobile 6 SDK and Compact Framework 3.5.
                  >
                  When you say "the code does not do the job" what exactly do you mean?
                  What does it do, and what do you want it to do?
                  >
                  Jon
                  Hi Jon

                  I think it is complete, Please create a windows application project
                  with smart device. Put the code under Form.cs. I don't think you
                  need to implement a 'Main'.

                  Regards,
                  Wan

                  Comment

                  • Wan

                    #10
                    Re: LINQ and XML for compact framework

                    On May 1, 11:44 am, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
                    On May 1, 10:56 am, Wan <luo...@gmail.c omwrote:
                    >
                    Here is the full sample code. with the XML sample.
                    >
                    Well, it's not exactly a full sample - it doesn't contain a Main
                    method, for instance. It's not even a complete class - where's the
                    implementation of InitializeCompo nent?
                    Hint: console apps are generally a lot shorter.
                    >
                    Seehttp://pobox.com/~skeet/csharp/incomplete.html
                    >
                    When I said the program was running, I mean the code was compiled.
                    However, the code does not do the job.  The project I created was
                    based on Windows Mobile 6 SDK and Compact Framework 3.5.
                    >
                    When you say "the code does not do the job" what exactly do you mean?
                    What does it do, and what do you want it to do?
                    >
                    Jon
                    'InitializeComp onent' method is generated when the project is
                    created. Since VS 2005, it is seperated from the form class.

                    Regards,
                    Wan

                    Comment

                    • Jon Skeet [C# MVP]

                      #11
                      Re: LINQ and XML for compact framework

                      On May 1, 12:43 pm, Wan <luo...@gmail.c omwrote:
                      I think it is complete,
                      No, it's definitely not.
                      Please create a windows application project
                      with smart device. Put the code under Form.cs. I don't think you
                      need to implement a 'Main'.
                      Only because Visual Studio creates another file for you that *does*
                      contain Main. Likewise the Form1.Designer. cs file contains
                      InitializeCompo nent. Without that, it's not complete.

                      In short, I can't cut and paste the code into a text editor *on its
                      own* and compile from the command line, which is what I tend to do
                      with newsgroup posts. Again, please read
                      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.


                      You also *still* haven't said how it behaves differently to how you
                      expect it to.

                      Jon

                      Comment

                      • Wan

                        #12
                        Re: LINQ and XML for compact framework

                        On May 1, 1:07 pm, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
                        On May 1, 12:43 pm, Wan <luo...@gmail.c omwrote:
                        >
                        I think it is complete,
                        >
                        No, it's definitely not.
                        >
                        Please create a windows application project
                        with smart device.  Put the code under Form.cs.  I don't think you
                        need to implement a 'Main'.
                        >
                        Only because Visual Studio creates another file for you that *does*
                        contain Main. Likewise the Form1.Designer. cs file contains
                        InitializeCompo nent. Without that, it's not complete.
                        >
                        In short, I can't cut and paste the code into a text editor *on its
                        own* and compile from the command line, which is what I tend to do
                        with newsgroup posts. Again, please readhttp://pobox.com/~skeet/csharp/incomplete.html
                        >
                        You also *still* haven't said how it behaves differently to how you
                        expect it to.
                        >
                        Jon
                        Ok, I am not sure if you complie it from command line will help to see
                        the problem. As the program was complied with no errors.

                        I expect this piece of code can go to the XML I pasted, and find the
                        element as well as changing the value. However, it didn't changed
                        value. even though it found the XML file, loaded XML, ran the LINQ
                        statement. Finally when I check the value of "IEnumerable<XE lement>
                        msgs" by watching this variable. It will give me such error message:


                        msgs.System.Col lections.Generi c.IEnumerator<T Source>.Current
                        'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
                        does not contain a definition for 'System' and no extension method
                        'System' accepting a first argument of type
                        'System.Collect ions.Generic.IE numerable<Syste m.Xml.Linq.XEle ment>'
                        could be found (are you missing a using directive or an assembly
                        reference?)

                        I assume, it might be problem of 'System.Collect ions.Generic' for
                        compact framework, does not support the XElement type.

                        Comment

                        • Wan

                          #13
                          Re: LINQ and XML for compact framework

                          On May 1, 1:07 pm, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
                          On May 1, 12:43 pm, Wan <luo...@gmail.c omwrote:
                          >
                          I think it is complete,
                          >
                          No, it's definitely not.
                          >
                          Please create a windows application project
                          with smart device.  Put the code under Form.cs.  I don't think you
                          need to implement a 'Main'.
                          >
                          Only because Visual Studio creates another file for you that *does*
                          contain Main. Likewise the Form1.Designer. cs file contains
                          InitializeCompo nent. Without that, it's not complete.
                          >
                          In short, I can't cut and paste the code into a text editor *on its
                          own* and compile from the command line, which is what I tend to do
                          with newsgroup posts. Again, please readhttp://pobox.com/~skeet/csharp/incomplete.html
                          >
                          You also *still* haven't said how it behaves differently to how you
                          expect it to.
                          >
                          Jon
                          The Program Has three files

                          1. Program.cs
                          using System;
                          using System.Linq;
                          using System.Collecti ons.Generic;
                          using System.Windows. Forms;

                          namespace xmlCFtest
                          {
                          static class Program
                          {
                          /// <summary>
                          /// The main entry point for the application.
                          /// </summary>
                          [MTAThread]
                          static void Main()
                          {
                          Application.Run (new Form1());
                          }
                          }
                          }


                          2. Form1.cs
                          using System;
                          using System.Linq;
                          using System.Collecti ons.Generic;
                          using System.Componen tModel;
                          using System.Data;
                          using System.Drawing;
                          using System.Text;
                          using System.Windows. Forms;
                          using System.Xml.Linq ;
                          using System.Xml;

                          namespace xmlCFtest
                          {
                          public partial class Form1 : Form
                          {
                          public Form1()
                          {
                          InitializeCompo nent();
                          updateMsg("1472 2", 5);
                          }

                          private void updateMsg(strin g MsgID, int newStatus)
                          {
                          try
                          {
                          lock ("Hello")
                          {
                          XmlReaderSettin gs settings = new
                          XmlReaderSettin gs();
                          settings.Confor manceLevel =
                          ConformanceLeve l.Fragment;
                          settings.Ignore Whitespace = true;
                          settings.Ignore Comments = true;
                          XmlReader reader = XmlReader.Creat e(@"Program Files
                          \messageclient\ XML\Inbox.xml", settings);

                          XElement root = XElement.Load(r eader);
                          IEnumerable<XEl ementmsgs = from el in
                          root.Descendant s("Message")
                          where
                          el.Element("Mes sageID").Value == MsgID
                          select el;

                          foreach (XElement el in msgs)
                          {

                          el.Element("Mes sageStaus").Set Value(newStatus .ToString());
                          }

                          root.Save(@"Pro gram Files\messagecl ient\XML
                          \Inbox.xml");
                          }
                          }
                          catch (Exception e) { }

                          }
                          }
                          }


                          3. Form1.Designer. cs
                          namespace xmlCFtest
                          {
                          partial class Form1
                          {
                          /// <summary>
                          /// Required designer variable.
                          /// </summary>
                          private System.Componen tModel.IContain er components = null;
                          private System.Windows. Forms.MainMenu mainMenu1;

                          /// <summary>
                          /// Clean up any resources being used.
                          /// </summary>
                          /// <param name="disposing ">true if managed resources should
                          be disposed; otherwise, false.</param>
                          protected override void Dispose(bool disposing)
                          {
                          if (disposing && (components != null))
                          {
                          components.Disp ose();
                          }
                          base.Dispose(di sposing);
                          }

                          #region Windows Form Designer generated code

                          /// <summary>
                          /// Required method for Designer support - do not modify
                          /// the contents of this method with the code editor.
                          /// </summary>
                          private void InitializeCompo nent()
                          {
                          this.mainMenu1 = new System.Windows. Forms.MainMenu( );
                          this.Menu = this.mainMenu1;
                          this.components = new System.Componen tModel.Containe r();
                          this.AutoScaleM ode =
                          System.Windows. Forms.AutoScale Mode.Dpi;
                          this.Text = "Form1";
                          this.AutoScroll = true;
                          }

                          #endregion
                          }
                          }

                          Regards,
                          Wan

                          Comment

                          • Jon Skeet [C# MVP]

                            #14
                            Re: LINQ and XML for compact framework

                            On May 1, 1:27 pm, Wan <luo...@gmail.c omwrote:
                            Ok, I am not sure if you complie it from command line will help to see
                            the problem.
                            It would if you would tell us how the program behaved differently to
                            how you expected - without referring to the debugger.
                            As the program was complied with no errors.
                            Yes, many short but complete programs do.
                            I expect this piece of code can go to the XML I pasted, and find the
                            element as well as changing the value. However, it didn't changed
                            value. even though it found the XML file, loaded XML, ran the LINQ
                            statement. Finally when I check the value of "IEnumerable<XE lement>
                            msgs" by watching this variable. It will give me such error message:
                            Yes, so you've said. That's in the debugger. Now, can you show a
                            program which produces output X when you expect output Y, without
                            having to break and look at the debugger? If it's *only* an issue with
                            the debugger, I'm unlikely to be able to help. If the program isn't
                            working as expected however, then please specify in what way that is
                            the case.

                            Here's an example of what I mean:

                            <sample post>
                            Problem: Addition with large numbers appears not to work.

                            I'm having trouble with addition when it comes to large integers

                            Program:
                            using System;

                            class Test
                            {
                            static void Main()
                            {
                            int i = 2147483647;
                            Console.WriteLi ne("i={0}", i);
                            Console.WriteLi ne("i+1={0}", i+1);
                            }
                            }

                            Expected output:
                            i=2147483647
                            i+1=2147483648

                            Actual output:
                            i=2147483647
                            i+1=-2147483648

                            Note that the result is negative. Why?
                            </sample post>

                            At this point:
                            a) I can easily compile and run the code
                            b) I can understand the problem
                            c I can verify that I see the problem too
                            d) I can easily change the code to try to fix it

                            Now obviously that's a trivial example - but it's a good model. While
                            you can only express what's wrong in terms of watching a variable in
                            the debugger, I'm inclined to put the issue down to a debugger
                            problem.

                            Jon

                            Comment

                            • Wan

                              #15
                              Re: LINQ and XML for compact framework

                              On May 1, 2:09 pm, "Jon Skeet [C# MVP]" <sk...@pobox.co mwrote:
                              On May 1, 1:27 pm, Wan <luo...@gmail.c omwrote:
                              >
                              Ok, I am not sure if you complie it from command line will help to see
                              the problem.
                              >
                              It would if you would tell us how the program behaved differently to
                              how you expected - without referring to the debugger.
                              >
                               As the program was complied with no errors.
                              >
                              Yes, many short but complete programs do.
                              >
                              I expect this piece of code can go to the XML I pasted, and find the
                              element as well as changing the value.  However, it didn't changed
                              value.  even though it found the XML file, loaded XML, ran the LINQ
                              statement.  Finally when I check the value of "IEnumerable<XE lement>
                              msgs" by watching this variable.  It will give me such error message:
                              >
                              Yes, so you've said. That's in the debugger. Now, can you show a
                              program which produces output X when you expect output Y, without
                              having to break and look at the debugger? If it's *only* an issue with
                              the debugger, I'm unlikely to be able to help. If the program isn't
                              working as expected however, then please specify in what way that is
                              the case.
                              >
                              Here's an example of what I mean:
                              >
                              <sample post>
                              Problem: Addition with large numbers appears not to work.
                              >
                              I'm having trouble with addition when it comes to large integers
                              >
                              Program:
                              using System;
                              >
                              class Test
                              {
                                  static void Main()
                                  {
                                      int i = 2147483647;
                                      Console.WriteLi ne("i={0}", i);
                                      Console.WriteLi ne("i+1={0}", i+1);
                                  }
                              >
                              }
                              >
                              Expected output:
                              i=2147483647
                              i+1=2147483648
                              >
                              Actual output:
                              i=2147483647
                              i+1=-2147483648
                              >
                              Note that the result is negative. Why?
                              </sample post>
                              >
                              At this point:
                              a) I can easily compile and run the code
                              b) I can understand the problem
                              c I can verify that I see the problem too
                              d) I can easily change the code to try to fix it
                              >
                              Now obviously that's a trivial example - but it's a good model. While
                              you can only express what's wrong in terms of watching a variable in
                              the debugger, I'm inclined to put the issue down to a debugger
                              problem.
                              >
                              Jon
                              The original XML file:

                              <?xml version="1.0"?>
                              <ArrayOfMessa ge xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
                              xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
                              <Message>
                              <IMEI xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">35 340401169569600 </IMEI>
                              <MessageText xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">hi </MessageText>
                              <MessageID xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">14 722</MessageID>
                              <UserID xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">12 984</UserID>
                              <SenderName xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">Ha rdCode Test </SenderName>
                              <TimeStamp xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">20 08-04-29T16:26:36.097 </TimeStamp>
                              <MessageStaus xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">3</MessageStaus>
                              </Message>
                              </ArrayOfMessage>



                              After run the program I wrote, I expect the XML to become:
                              <?xml version="1.0"?>
                              <ArrayOfMessa ge xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
                              xmlns:xsd="http ://www.w3.org/2001/XMLSchema">
                              <Message>
                              <IMEI xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">35 340401169569600 </IMEI>
                              <MessageText xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">hi </MessageText>
                              <MessageID xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">14 722</MessageID>
                              <UserID xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">12 984</UserID>
                              <SenderName xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">Ha rdCode Test </SenderName>
                              <TimeStamp xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">20 08-04-29T16:26:36.097 </TimeStamp>
                              <MessageStaus xmlns="http://FleetMatics.com/WCFMessageServi ce/
                              Message.xsd">5</MessageStaus>
                              </Message>
                              </ArrayOfMessage>

                              The last element <MessageStaus ></MessageStaussho uld change its
                              value.

                              Actual Output has nothing changed. However, if I created a normal
                              framework console application project. And copy, paste this code, it
                              will do the job. That's why I want to ask how to use LINQ to modify
                              XML in compact framework.


                              Wan





                              Comment

                              Working...