-1

can you please help me with this code. Thank you.

In this code under the word Today a warning : an embedded expression cannot be used here

Dim doc = _
New XElement("Books", _
New XElement("Book", _
New XAttribute("ISBN", "0000000000001"), _
New XAttribute("RecordDate", <%= Today %>), _
New XElement("Price", 11.95), _
New XElement("Name", "Book Title 1"), _
New XElement("Stock", _
New XAttribute("InStock", 12), _
New XAttribute("OnOrder", 24))))
Laszlo Boke
  • 1,319
  • 1
  • 10
  • 22
ebello
  • 1

1 Answers1

0

Looks like you are trying to code like in asp.net, Try changing the usage as below:

New XAttribute("RecordDate", DateTime.Today)

If you want to use embedded expressions, you do not need to use Linq-to-xml construction using new XAtrribute etc. but you can do it directly constructiong the xml as show in this example

Flowerking
  • 2,551
  • 1
  • 20
  • 30
  • Code in book "Visual Basic 2010" , Author: Evangelos Petroutsos, page 599. If you google it you can find this e-book. – ebello Jan 30 '13 at 16:59