Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

vb.net XML document

Posted on 2014-03-18
3
Medium Priority
?
212 Views
Last Modified: 2014-03-18
The below code is part of a loop that successfully populates xApplicationLog

The question is how do I empty the contents of xApplicationLog prior to this loop running?



                            Dim xLOG As New XElement("LOGs")
                            xLOG.Add(New XElement("InstanceID", objEntry.InstanceId.ToString))
                            xLOG.Add(New XElement("ErrorTime", CDate(objEntry.TimeGenerated.ToString)))
                            xLOG.Add(New XElement("ErrorSource", objEntry.Source.ToString))
                            xLOG.Add(New XElement("ErrorMessage", objEntry.Message.ToString))
                            xApplicationLog.Add(xLOG)
0
Comment
Question by:dastaub
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 39937445
Assuming xApplicationLog is an XElement object then you can call the RemoveNodes() method to clear any child nodes:
xApplicationLog.RemoveNodes()

'// rest of your code

Open in new window

0
 

Author Comment

by:dastaub
ID: 39937636
...Assuming xApplicationLog is an XElement object

below is the creation of xApplicationLog, so I assume that makes it an XElement?

   Public xApplicationLog As New XElement("ApplicationLog")
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 39937674
It does indeed.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question