0

I need to display the Name of the Start tag and the end tag at appropriate positions while parsing an xml file. I have to use other method than using startElement and endElement functions. Below is an example as how I expect my output to be.

`<?xml version="1.0" encoding="ASCII"?>
<Employee-Detail>
<Employee>
  <Emp_Id>E-001</Emp_Id>
  <Emp_Name>
  <First_Name>Mani</First_Name>
  <Last_Name>Maran</Last_Name>
  </Emp_Name>
  <Emp_E-mail>[email protected]</Emp_E-mail> 
  </Employee>
</Employee-Detail>
`

Output: StartTag:Employee-Detail StartTag:Employee StartTag:Emp_Id Value:E-001 EndTag:Emp_Id StartTag:Emp_Name StartTag:First_Name Value:Mani EndTag:First_Name StartTag:Last_Name Value:Maran EndTag:Last_Name EndTag:Emp_Name StartTag:Emp_E-mail Value:[email protected] EndTag:Emp_E-mail EndTag:Employee EndTag:Employee-Detail

3
  • 1
    ? I have no clue what you are asking.. ?
    – FailedDev
    Apr 20, 2012 at 14:18
  • I need to parse the xml document and in the console have to print the tags along with the values correspondingly (The position of start tag and end tag should be as in the xml) without using the startElement and endElement methods.
    – Mani
    Apr 20, 2012 at 14:22
  • Not using a particular method (or two) is a bizarre requirement (there might be a reason for it, but that reason needs to be explained so any alternative solution can avoid whatever problem those methods introduce). That said, those methods don't exist in the context of the question. What code have you got so far. What programming language are you using? Why do you need to output this particular data structure (the XML is perfectly good)?
    – Quentin
    Apr 20, 2012 at 15:06

1 Answer 1

-1

using SAX parser will allow you to parse XML line by line and emit output that you wanted

1
  • can you please post an example ?
    – Mani
    Apr 20, 2012 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.