Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading XML

Posted on 2006-11-20
6
Medium Priority
?
257 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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

604 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