remove 2 empty XML nodes


I have the following XML which I need to remove the 2 elements that are empty, can someone provide the code to achieve this please?

I'm using ASP XMLDoc if that matters?

These need to go:

<?xml version="1.0" encoding="UTF-8"?>
<fod:Doc xmlns:fod="">
    <M3JobType>Missed Bin</M3JobType>
    <M3JobType>Missed Bin</M3JobType>

Open in new window

Neil ThompsonSenior Systems DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]Billing EngineerCommented:
why do you want to remove them?
and is the XML the first place to start with, or is it on the generation of the XML you may want to skip them being created?

in vbscript, using the xml "plain string", I would eventually do a plain "replace" of
"<WorksheetId></WorksheetId>" by "" and "<M3JobType></M3JobType>" by "" ...
Neil ThompsonSenior Systems DeveloperAuthor Commented:
The XML is coming from another system so I cannot stop them being created unfortunately so need to work on the XML itself before I pump it on.

I've found out this is the way to do it:

	Set myNode = XMLDoc.SelectSingleNode("//WorksheetId")
	Set myNode = XMLDoc.SelectSingleNode("//M3JobType")

Open in new window

Guy Hengel [angelIII / a3]Billing EngineerCommented:
that is indeed a "pure xml" way to do it.
however, I must presume that it is likely not as efficient as the simple string replace method.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Neil ThompsonSenior Systems DeveloperAuthor Commented:
Thanks Guy, Appreciate the assistance
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.