My Assistant
![]() ![]() |
|
|
May 30 2012, 08:52 PM
Post
#1
|
|
|
UtterAccess Editor Posts: 6,718 From: Capital District, NY, USA |
Hi,
I'm trying to write out an xml element from C# that includes both and opening and closing tag rather than the "compact" (term?) version: <Element></Element> instead of: <Element /> By default, if the element contains no data, it's written in the second, compact format. How can I specify the first format? I'm using Linq to XML to generate the base file. Essentially this is a collection container that will be filled at a later point: CODE <Root> <SomeSet> <ChildToAddLater /> <ChildToAddLater /> </SomeSet> </Root> Perhaps I should take a different approach and completely omit the "SomeSet" element until there's data to go in the set, thus handling it on the read end instead (looking for the nonexistance of SomeSet rather than the nonexistance of its' children?). I'd prefer to have the blank set elements in place as part of the initial template writeout, but I'm open to ideas. Thanks much, -jack |
|
|
|
May 30 2012, 08:56 PM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 48,018 From: SoCal, USA |
Hi Jack,
Would using a placeholder character that you could just replace later be an option for you? Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
May 30 2012, 08:58 PM
Post
#3
|
|
|
UtterAccess Editor Posts: 6,718 From: Capital District, NY, USA |
I could add a temp child or even inner text in there during creation then remove it after it's written, but that seems a little clunky to me (especially with two writes involved at that point).
The app will take action based on the presence of children in the set, so it's not something I could just leave laying around either. |
|
|
|
Jul 10 2012, 11:51 AM
Post
#4
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
I think that is all driven by LinqToXML and other aspects of XML libraries in .Net. If you want to write in an explicit format, you'll likely have to roll your own routine.
|
|
|
|
Jul 10 2012, 11:59 AM
Post
#5
|
|
|
UtterAccess Editor Posts: 6,718 From: Capital District, NY, USA |
It ended up being a non-issue anyway... I wound up using Linq to query the set, and it easily returns any results or lack thereof, and when writing thus handling the closing tag accordingly. Didn't matter in the end (which is probably why there's no handy option to do so)
Cheers, |
|
|
|
Jul 10 2012, 01:08 PM
Post
#6
|
|
|
UtterAccess Editor Posts: 15,974 From: Northern Virginia, USA |
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 22nd May 2013 - 07:07 PM |