MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

XML Parser: Reading between angle bracket

  Asked By: Leona    Date: Jan 03    Category: MS Office    Views: 2162

I am writing a XML to excel Parser.Now in XML I have
some value between angle brackets (<>) and i want to
read that value and want to display it in excel.

For e.g <3456>

I want to write a code which first see "<" and then
see ">" and read the text between the bracket and
display it in excel.

Can some one tell me How can i do this?



6 Answers Found

Answer #1    Answered By: Jakson Williams     Answered On: Jan 03

You would step through each character in a string (the whole or part of the
XML file) and compare each character "<"

when you found it you would then continue to step through the string comparing
each character with ">", other characters would be added to a string variable.

When you hit the ">" You would (either in the process or subsequently) test
the content of the string variable to see if it represented a valid numerical

Then you would make the value of the relevant cell in your spreadsheet equal
to either the numeric value (using cLng or a similar casting function) or the
string value directly.

Answer #2    Answered By: Abney Martin     Answered On: Jan 03

You need to use the InStr VBA function to find the starting and ending
position of the brackets, however, brackets  are common in XML/HTML code,
and you are better off finding a unique value closest to the "<" bracket
first before moving onto breaking out the data.

Look up the use of InStr, to learn how to find the position (numeric)
location of a text  string. Then write  your code  to find the position of
the unique value mentioned above, then the starting and ending positions
of the brackets there after. Once you have these positions you can pull
the data from between them.

Answer #3    Answered By: Fannie Gonzales     Answered On: Jan 03

But ... this doesn't sound like XML to me. It's the tags that go inside the
angle brackets  in XML, not the values. (Or possibly inside the angle
brackets, but to the right of an equals sign, and enclosed in quotes.) Are
you sure that's the actual format of your XML?

Answer #4    Answered By: Mason Evans     Answered On: Jan 03

I have never dealt with XML directly and
(by the sound of it I am lucky!) and was only answering the specific question.

I thought MS sold or gave away an XML parser  that pulls the XML into excel.
But this was in the early days of XML. Many years ago - well, about 6 or 7
years, I suppose.

Anyhow, if I was faced with that problem I would try googling and see if
someone has already done it.

Answer #5    Answered By: Ludwik Fischer     Answered On: Jan 03

Was handed an updated JSP file today with: "we've changed the business logic
in parts of this, could you update the XSL to match please". (This JSP and
the XSL do similar things for a screen display  and a generated PDF,
respectively.) So not only was I back with XML, I was comparing the logic
in two dissimilar XML-based transformers.

One has to wonder at the logic / common sense of the (presumably) clever
people who designed two similar transformation engines but used quite
incompatible syntax for things like variables, conditionals, etc.

I didn't have much hair before, but I've now pulled the rest out.

Answer #6    Answered By: Rayner Fischer     Answered On: Jan 03

Excel 2003 will open XML files and offers several ways of handling them.
Don't know about previous versions, though.

Didn't find what you were looking for? Find more on XML Parser: Reading between angle bracket Or get search suggestion and latest updates.