Solved

Reading XML

Posted on 2006-11-20
6
232 Views
Last Modified: 2013-11-19
I am reading an XML file through the MSXML2.IXMLDOMNode.

Partof my XML looks something like this:

   <UseDefaultAddressFlag value="Yes"/>

I can't seem to find any attribute of IXMLDOMNode that will retrieve the value ("Yes", in the above case)

How do I retrieve the value?
0
Comment
Question by:Clif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 17979695
n.Attributes.getNamedItem("value").Text
0
 
LVL 10

Author Comment

by:Clif
ID: 17979789
That gives me an "Object variable or With block variable not set:

Works:
Debug.Print "> " & objNode.nodeName & " - (" & objNode.Text & ")"

Errors:
Debug.Print "> " & objNode.nodeName & " - (" & objNode.Text & ") - <" & objNode.Attributes.getNamedItem("value").Text & ">"

(In both above cases objNode has been set to MSXML2.IXMLDOMNode, I am using the Microsoft XML v4.0 library))
0
 
LVL 10

Author Comment

by:Clif
ID: 17980320
I discovered why I was getting the error.

Some tags do not have a value attribute.  So, is there a way (aside from "On Error Resume Next") to not cause an error when I run across tags that don't have a "value" attribute?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:Clif
ID: 17980418
I went ahead and accepted the answer because it was the correct answer.

If you can answer the second question, more's the better.  :)
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17994290
Glad I could help, sorry for the late response (i got my emails from EE with up to 3 days of delay :-(

>So, is there a way (aside from "On Error Resume Next") to not cause an error when I run across tags that don't have a "value" attribute?
I have not seen a function to return that information, but you could of course loop on the attributes collection to find the one you are looking for.
however, if there will be alot of attributes in general, that method will cost alot more time than the ON ERROR methods...
0
 
LVL 10

Author Comment

by:Clif
ID: 17995143
Thanks.

On Error will work, of course, but it's never the preferrred solution.  Looping through the attributes to find out if the one I want is there would be more unneccesary coding than on On Error would be, so I'll stick with that.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question