0

I am writing an application with C# for Windows CE. I want to convert the data read from a XML ( in string format) to XElement format and then set it to a meter. I have used XElemenet.parse() to convert my data. But when I want to set my data I get an error saying invalid data or XML.

The same procedure works perfectly on a Windows Form Application but it does not run on Windows CE. Any idea? Does Windows CE even support Xelement.parse()?

Here it is the string output

"<Array><Structure><LongUnsigned>8</LongUnsigned><OctetString>0000010000FF</OctetString><Integer>2</Integer><LongUnsigned>0</LongUnsigned></Structure><Structure><LongUnsigned>3</LongUnsigned><OctetString>0100010800FF</OctetString><Integer>2</Integer><LongUnsigned>0</LongUnsigned></Structure></Array>"

And the converted data by Xelement.parse();

<Array>
  <Structure>
    <LongUnsigned>8</LongUnsigned>
    <OctetString>0000010000FF</OctetString>
    <Integer>2</Integer>
    <LongUnsigned>0</LongUnsigned>
  </Structure>
  <Structure>
    <LongUnsigned>3</LongUnsigned>
    <OctetString>0100010800FF</OctetString>
    <Integer>2</Integer>
    <LongUnsigned>0</LongUnsigned>
  </Structure>
  <Structure>
    <LongUnsigned>3</LongUnsigned>
    <OctetString>0100010801FF</OctetString>
    <Integer>2</Integer>
    <LongUnsigned>0</LongUnsigned>
  </Structure>
  <Structure>
    <LongUnsigned>3</LongUnsigned>
    <OctetString>0100010802FF</OctetString>
    <Integer>2</Integer>
    <LongUnsigned>0</LongUnsigned>
  </Structure>
  <Structure>
    <LongUnsigned>3</LongUnsigned>
    <OctetString>0100010803FF</OctetString>
    <Integer>2</Integer>
    <LongUnsigned>0</LongUnsigned>
  </Structure>
</Array>

And Finally The Error

Invalid data or XML:
    <Array>
      <Structure>
        <LongUnsigned>8</LongUnsigned>
        <OctetString>0000010000FF</OctetString>
        <Integer>2</Integer>
        <LongUnsigned>0</LongUnsigned>
      </Structure>
      <Structure>
        <LongUnsigned>3</LongUnsigned>
        <OctetString>0100010800FF</OctetString>
        <Integer>2</Integer>
        <LongUnsigned>0</LongUnsigned>
      </Structure>
      <Structure>
        <LongUnsigned>3</LongUnsigned>
        <OctetString>0100010801FF</OctetString>
        <Integer>2</Integer>
        <LongUnsigned>0</LongUnsigned>
      </Structure>
      <Structure>
        <LongUnsigned>3</LongUnsigned>
        <OctetString>0100010802FF</OctetString>
        <Integer>2</Integer>
        <LongUnsigned>0</LongUnsigned>
      </Structure>
      <Structure>
        <LongUnsigned>3</LongUnsigned>
        <OctetString>0100010803FF</OctetString>
        <Integer>2</Integer>
        <LongUnsigned>0</LongUnsigned>
      </Structure>
    </Array>
Mah Fa
  • 13
  • 4
  • A _partial_ screenshot of an error wil probably be helpful for solving this. Put error messages as text, not a screenshot. – Uwe Keim Feb 18 '19 at 06:43
  • I think your output XML doesn't contain XML declaration and that's why windows CE doesn't recognize this file as a XML – er-sho Feb 18 '19 at 06:44
  • My output data to set should be like this.i don't know what should i do to solve my problem :( – Mah Fa Feb 18 '19 at 07:04
  • Can you parse a simpler form of this XML? For instance just one Structure node or even just one property in it. If that works, then add more data. Try and see if you can pinpoint the problem – Hans Kesting Feb 18 '19 at 07:09
  • I did it but still the same Error! – Mah Fa Feb 18 '19 at 07:13

0 Answers0