1

I have an unformatted XML file like this:

<ROOT>
    <A0>Hi</A0>
    <A1 A="hi" A="how" A="are" A="You?"></A1>
    <A2 A2="Bye"> </A2>
    <A3>In this tag have hexadecimal value</A3>
</ROOT>

Questions:

  1. how do I handle duplicate attribute name like in tag <A1> ?
  2. how do I handle hexadecimal values like in tag <A3> ?

I have to use this type of files as a source in a SSIS package.

Thanks

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ram.bi
  • 283
  • 4
  • 15
  • 5
    1. A well-formed XML document can't have identically-named attributes. 2. It isn't clear what you mean by `"How handle Hexadecimal values "` you haven't said exactly in what way you want these processed. Please, edit the question and make it more meaningful. – Dimitre Novatchev Apr 10 '12 at 12:49
  • If that are your requirements, then your files are not XML-files ;). You will probably encounter lots of trouble if you try working with some existing parsers, and those that will work might eg. stop in next (or previous) version. I think I would try with some HTML-oriented parsers, as there are some crazy websites out there so they might not be so choosy about contents of your documents. – j_kubik Jun 20 '14 at 02:58

1 Answers1

12
<ROOT>
  <A0>Hi</A0>
  <A1 A="hi" A="how" A="are" A="You?"></A1>
  <A2 A2="Bye"> </A2>
  <A3>In this tag have Hexa deimal value </A3>
</ROOT>

Duplicate attributes (on the same element) are not allowed in a well-formed XML document by definition.

Therefore the provided text isn't an XML document, cannot be parsed by any compliant XML parser -- and therefore, the described problem cannot exist.

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • Thanks for quick reply. Is there any solution to over come Hexadecimal values Like (^ not exact somthing like reverse L shape). – ram.bi Apr 10 '12 at 12:50
  • @ram.bi: You haven't described at all what processing of hexadecimal values you want. – Dimitre Novatchev Apr 10 '12 at 12:51
  • From my source XML i am getting some hexadecimal values (Different symbols like reverse L etc,). XML Not processing those values how can i handle those? – ram.bi Apr 10 '12 at 13:00
  • Please, ask a new question. Provide a well-formed XML document (verify in advance that it is parsed without errors). Have exact text nodes and specify explicitly what are the unwanted characters and what characters you would like to have. Statements like "XML not processing those values" are confusing. What do you mean by this? – Dimitre Novatchev Apr 10 '12 at 13:12
  • i am getting following error::Character ' ', hexadecimal value 0x2 is illegal in XML documents. – ram.bi Apr 10 '12 at 13:41
  • Yes, in XML 1.0 the only allowed characters with code below x20 are CR, NL and Tab (`0xD`, `0xA` and `9`). An XML 1.0 document must not contain any other characters with codes below x20. – Dimitre Novatchev Apr 10 '12 at 14:33