login about faq

Hello all,

I've managed to work out how to get to everything on this xml file, but these parts. I cannot for the life of me figure out what i need to do. Any help or pointers would be great, Im using VB6. I want a way to get hold of the data (BUL-BUlletin) in Value="BUL - Bulletin" as below.

Thank you.

  <?xml version="1.0" encoding="UTF-8" ?> 
  <Catalog Href="" /> 
  <Language FormalName="en-GB" /> 
  <OfInterestTo FormalName="all" /> 
  <Property FormalName="Category" Value="BUL - Bulletin" /> 

asked Mar 13 '16 at 16:32

Chrisw100's gravatar image


edited Mar 14 '16 at 10:29

jpbro's gravatar image

jpbro ♦

Thanks jpbro!

The SearchForAttribute method is good if you don't know where the attribute is located within the XML document. However, it can be expensive because it's traversing the XML document looking for it..

If you already know the exact location of what you need to get, then ChilkatPath is best:

Dim x As New ChilkatXml 
x.LoadXml(App.Path & "600002.xml") 
MsgBox x.ChilkatPath("NewsML|NewsEnvelope|NewsItem|Identification|NewsManagement|NewsComponent|DescriptiveMetadata|Property|(Value)")


answered Mar 14 '16 at 21:03

chilkat's gravatar image

chilkat ♦♦

Nice :) I haven't used ChilkatXml much as my apps don't do much if any XML work, so I was unaware of the ChilkatPath method - very handy!

(Mar 15 '16 at 03:48) jpbro ♦

Thank you jpbro. Just had to tweak it as object variable or with variable not set - error 91.

But thank you for pointing me to the answer, really appreciated.

FYI Just changed to this to avoid the error. Dim x As New ChilkatXml MsgBox x.LoadXml(App.Path & "600002.xml") MsgBox x.SearchForAttribute(x.GetRoot, "Property", "Value", "*").GetAttrValue("Value")


answered Mar 14 '16 at 18:39

Chrisw100's gravatar image


Glad to help - thanks for catching the unset object, I copied & pasted the code and forgot to update the temporary X variable I had to the correctly named lo_Xml.

(Mar 14 '16 at 19:49) jpbro ♦

This seems to work:

   Dim lo_Xml As Chilkat_v9_5_0.ChilkatXml

Set lo_Xml = New ChilkatXml

If lo_Xml.LoadXML("C:\test.xml") = 1 then
      Debug.Print lo_Xml.SearchForAttribute(lo_Xml.GetRoot, "Property", "Value", "*").GetAttrValue("Value")
   End If

Side note - it looks like your XML is invalid - there's no closing tags for Identification, NewsManagement or ContentItem. Not sure if this will cause adverse effects or not.


answered Mar 14 '16 at 11:21

jpbro's gravatar image

jpbro ♦

edited Mar 14 '16 at 19:49

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Mar 13 '16 at 16:32

Seen: 1,273 times

Last updated: Mar 15 '16 at 03:48

powered by OSQA