Re: LINQ and XML for compact framework
- From: Wan <luowan@xxxxxxxxx>
- Date: Thu, 1 May 2008 06:21:24 -0700 (PDT)
On May 1, 2:09 pm, "Jon Skeet [C# MVP]" <sk...@xxxxxxxxx> wrote:
On May 1, 1:27 pm, Wan <luo...@xxxxxxxxx> wrote:
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<XElement>
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.WriteLine("i={0}", i);
Console.WriteLine("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"?>
<ArrayOfMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Message>
<IMEI xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">35340401169569600</IMEI>
<MessageText xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">hi</MessageText>
<MessageID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">14722</MessageID>
<UserID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">12984</UserID>
<SenderName xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">HardCode Test </SenderName>
<TimeStamp xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">2008-04-29T16:26:36.097</TimeStamp>
<MessageStaus xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">3</MessageStaus>
</Message>
</ArrayOfMessage>
After run the program I wrote, I expect the XML to become:
<?xml version="1.0"?>
<ArrayOfMessage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Message>
<IMEI xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">35340401169569600</IMEI>
<MessageText xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">hi</MessageText>
<MessageID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">14722</MessageID>
<UserID xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">12984</UserID>
<SenderName xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">HardCode Test </SenderName>
<TimeStamp xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">2008-04-29T16:26:36.097</TimeStamp>
<MessageStaus xmlns="http://FleetMatics.com/WCFMessageService/
Message.xsd">5</MessageStaus>
</Message>
</ArrayOfMessage>
The last element <MessageStaus></MessageStaus> should 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
.
- Follow-Ups:
- Re: LINQ and XML for compact framework
- From: Jon Skeet [C# MVP]
- Re: LINQ and XML for compact framework
- References:
- Re: LINQ and XML for compact framework
- From: Jon Skeet [C# MVP]
- Re: LINQ and XML for compact framework
- From: Wan
- Re: LINQ and XML for compact framework
- From: Jon Skeet [C# MVP]
- Re: LINQ and XML for compact framework
- From: Wan
- Re: LINQ and XML for compact framework
- From: Jon Skeet [C# MVP]
- Re: LINQ and XML for compact framework
- From: Wan
- Re: LINQ and XML for compact framework
- From: Jon Skeet [C# MVP]
- Re: LINQ and XML for compact framework
- Prev by Date: Re: public declaration question
- Next by Date: Re: Quick way to convert int to array of numbers
- Previous by thread: Re: LINQ and XML for compact framework
- Next by thread: Re: LINQ and XML for compact framework
- Index(es):
Relevant Pages
|
Loading