XDocument class not recognised

D

dev100

Hi, we are trying to get some code previously compiled in 3.5 CF
into a V2.0 CF build using VS2008 The compiler doesn't like the XDocument
class.
Looking around the docs it appears that XmlDocument is the closest
equivalent from CF 2.0. Is this correct?

Thanks
 
S

Simon Hart [MVP]

XDocument is a CF 3.5 class part of the System.Xml.Linq namespace (CF 3.5
namespace). You can't use this on CF 2.0.

You can use anything in System.Xml on CF 2.0 and yes XmlDocument is one way
of parsing XML on CF 2.0.
 
S

Simon Hart [MVP]

XDocument is a CF 3.5 class part of the System.Xml.Linq namespace (CF 3.5
namespace). You can't use this on CF 2.0.

You can use anything in System.Xml on CF 2.0 and yes XmlDocument is one way
of parsing XML on CF 2.0.
 
D

dev100

Thanks, how to get an element by the tag name, it seems there is only
GetElementsByTagName which returns a list of nodes.
eg if i have this

<product>
<name>Prod1</name>
<id>1000</id>
<price>25.98</price>
</product>

So if i want to directly get the value of id, how to easily get without
iterating through the product list of tags one by one

foreach (XmlElement e in xmlDoc.GetElementsByTagName("product")) // this
gives me the product tag

{

// how do i just get the value of the id or price here without iterating
the list

}


Simon Hart said:
XDocument is a CF 3.5 class part of the System.Xml.Linq namespace (CF 3.5
namespace). You can't use this on CF 2.0.

You can use anything in System.Xml on CF 2.0 and yes XmlDocument is one
way of parsing XML on CF 2.0.

--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com




__________ Information from ESET Smart Security, version of virus
signature database 4091 (20090520) __________

The message was checked by ESET Smart Security.

http://www.eset.com



__________ Information from ESET Smart Security, version of virus signature database 4091 (20090520) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
D

dev100

Thanks, how to get an element by the tag name, it seems there is only
GetElementsByTagName which returns a list of nodes.
eg if i have this

<product>
<name>Prod1</name>
<id>1000</id>
<price>25.98</price>
</product>

So if i want to directly get the value of id, how to easily get without
iterating through the product list of tags one by one

foreach (XmlElement e in xmlDoc.GetElementsByTagName("product")) // this
gives me the product tag

{

// how do i just get the value of the id or price here without iterating
the list

}


Simon Hart said:
XDocument is a CF 3.5 class part of the System.Xml.Linq namespace (CF 3.5
namespace). You can't use this on CF 2.0.

You can use anything in System.Xml on CF 2.0 and yes XmlDocument is one
way of parsing XML on CF 2.0.

--
Simon Hart
Visual Developer - Device Application Development MVP
http://www.simonrhart.com




__________ Information from ESET Smart Security, version of virus
signature database 4091 (20090520) __________

The message was checked by ESET Smart Security.

http://www.eset.com



__________ Information from ESET Smart Security, version of virus signature database 4091 (20090520) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top