Menu

problems deleting last child

majik
2007-09-13
2013-05-20
  • majik

    majik - 2007-09-13

    When I have a portion of an XML file as follows:

    <EMPLOYEE Name="Bob SMith">   
        <DUTIES TaskName="answer phones" Priority"1">
        <DUTIES TaskName="follow-up pending cases" Priority"2">
        <DUTIES TaskName="assist Tom" Priority"3">
    </EMPLOYEE>

    and I delete DUTIES one at a time, if I delete all within EMPLOYEE then save the file, it gets saved as:

    <EMPLOYEE Name="Bob SMith" />   

    instead of:
    <EMPLOYEE>
    </EMPLOYEE>

    Is that how it should work? Is there a way to save it as
    <EMPLOYEE>
    </EMPLOYEE> ?? If so, do I need to delete the last child a certain way?

     
    • majik

      majik - 2007-09-13

      Note: I accidentally left out an equal sign after Priority

      Well, I did the obvious and tried adding a DUTIES tag and it does go back to the format
      <EMPLOYEE Name="Bob SMith"> 
      <DUTIES TaskName="something" Priority="something">
      </EMPLOYEE>

       
    • Lee Thomason

      Lee Thomason - 2007-09-15

      majik--

      This:

      <EMPLOYEE Name="Bob SMith" />
      and
      <EMPLOYEE Name="Bob SMith">
      </EMPLOYEE>

      ...mean exactly the same thing. the '/>' syntax closes a tag. TinyXML always prefers the concise syntax. If you want the more verbose expression, you could modify (or write your own) TiXmlPrinter.

      lee

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.