Thread: regarding xml

  1. #1
    Registered User
    Join Date
    Aug 2006
    Posts
    90

    regarding xml

    i have an xml file
    likethis
    <EMAIL>
    <[email protected]>
    <DT:07:06:2007>
    <RED Time=11:30:46>hi</RED>
    </DT:07:06:2007>
    </[email protected]>
    </EMAIL>
    i want add elements to the <DT:..> tag
    but when i parse the file ika gettinh parser error at "@",":".
    so without parse how can add and retrieve the dat from xml
    thank u

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    http://www.w3.org/TR/REC-xml/
    Because they're not valid XML names perhaps?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    90
    yah
    but is there anyway we can add or retreive data without parsing the document

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    Build your own non-xml parser I guess.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    90
    thank u for ur reply
    how we can built non-xml and how can we add and retrieve our data.

  6. #6
    Lean Mean Coding Machine KONI's Avatar
    Join Date
    Mar 2007
    Location
    Luxembourg, Europe
    Posts
    444
    Either you're using XML or you don't. If you use incorrect element names, you're not using XML and the whole advantage of XML is to be exploitable easily. Think about it ... either write an ENTIRE PARSER or change one friggin element name.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Code:
    <EMAIL>
    <[email protected]>
    <DT:07:06:2007>
    <RED Time=11:30:46>hi</RED>
    </DT:07:06:2007>
    </[email protected]>
    </EMAIL>
    With XML you also have to quote attributes, that is,
    Code:
    <RED Time=11:30:46>hi</RED>
    must be
    Code:
    <RED Time="11:30:46">hi</RED>
    XML elements are also usually lowercase, but that's not required.

    Anyway, it would be relatively simple to write a program which changes
    Code:
    <DT:07:06:2007>
    </DT:07:06:2007>
    into
    Code:
    <DT date="07:06:2007">
    </DT>
    In fact, here's a Perl script which will do it for you:
    Code:
    $ perl -pe 's/<DT:(\d\d:\d\d:\d{4,4})>/<DT date="$1">/;s|</DT[:\d]+>|</DT>|'
    Sorry, couldn't resist.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Parsing Xml
    By deviousdexter in forum C# Programming
    Replies: 7
    Last Post: 04-24-2009, 06:29 AM
  2. Dissecting an Excel XML spreadsheet
    By desmond5 in forum C++ Programming
    Replies: 1
    Last Post: 05-22-2008, 04:32 PM
  3. XML encoding issue
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-16-2008, 05:21 AM
  4. XML and data exchange
    By seexml in forum C Programming
    Replies: 0
    Last Post: 04-27-2006, 03:02 PM
  5. Need help with this xml tree example
    By kzar in forum C Programming
    Replies: 1
    Last Post: 11-22-2004, 11:23 AM