Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vb6 xml remove nodes problem

Options
  • 23-03-2004 10:37am
    #1
    Closed Accounts Posts: 843 ✭✭✭


    I hope someone can help here. I've sent this problem to all of my mates and not one answered the mail. Usually they want to show off and have a race to answer but i think this one has them all stumped.

    My problem is that i have been given an XML file which has a lot of '~' values (denoteing that i have to remove this node).
    These symbols can be anywhere in the XML.
    Does anyone know how to parse the file and remove the offending nodes?

    I've tried so many things but none turn out to be a complete solution.

    Here is a sample. so in this one i would have to remove
    <AddressLine2>~</AddressLine2>
    <AddressLine4>~</AddressLine4> etc

    I will never know the path as new stuff could be added to the file at anytime.

    Anyone who helps can be officialy crowned a genius on this one.
    Thanks






    <Changes>
    <AddressChange>
    <Employee>
    <PostalAddress type="undefined">
    <Address>
    <AddressLine1>14 Jona Street</AddressLine1>
    <AddressLine2>~</AddressLine2>
    <AddressLine3></AddressLine3>
    <AddressLine4>~</AddressLine4>
    <City>Burwoods</City>
    <PostalCode>~</PostalCode>
    <CountryCode>AUS</CountryCode>
    </Address>
    </PostalAddress>
    </Employee>
    </AddressChange>
    <OtherChange>
    <Employee>
    <CriminalRecord type="undefined">
    <Crime>
    <Murder>14 Jona Street</Murder>
    <PostalCode>~</PostalCode>
    <CountryCode>AUS</CountryCode>
    </Crime>
    </CriminalRecord>
    </Employee>
    </OtherChange>
    </Changes>


Comments

  • Registered Users Posts: 629 ✭✭✭str8_away


    have you tried DOMDocument30 object?
    use loadXML to create your node collection
    parse through the children nodes and use removeChild to remove node you donot want.

    One thing to watch out is if you are using DTD.
    After some node are removed it miy not be valid according to DTD.


  • Closed Accounts Posts: 843 ✭✭✭DaithiSurfer


    Hi str8_away,
    Thats the way we were trying to do it. The problem is that we can parse through the document OK with a recursive call but removeing the node is the problem. We are not validating it for the moment until we get this to work though.
    You wouldn't be able to point me to some examples on the net would you.
    Thanks again.


  • Registered Users Posts: 629 ✭✭✭str8_away


    What kind of error are you having?
    post your code and I will take a look.

    Did a quick search on google and this sample code might be some help
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmmthremovechild.asp
    http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/426/qid/747131


  • Closed Accounts Posts: 843 ✭✭✭DaithiSurfer


    We've tried lots of different bits of and they all didnt work, so we've deleted it and are starting from scratch.

    Its not that we got errors, iuts removing the nodes thats the problem.
    I'll check your links and let you know how it goes.
    Thanks for your help. I hate XML :)


Advertisement