Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Need help with XML

May
12,834
163
When DevStudio kept info in the registry I used a BTM (assigned to a PowerPro button) to open my most recent programming project. VS2019 uses an XLM file (21KB with no newlines!) to store such info. I know nothing about XML or TCC's functions to deal with it. Here's a snippet from that file (with some newlines thrown in). It's a bit more complicated than the example in TCC's help.

Code:
<collection name="CodeContainers.Offline">
<value name="value">
[
{"Key":"P:\\Hello\\Hello.sln","Value":{"LocalProperties":{"FullPath":"P:\\Hello\\Hello.sln","Type":0,"SourceControl":null},"Remote":null,"IsFavorite":false,"LastAccessed":"2020-04-02T22:12:51.7492686+00:00","IsLocal":true,"HasRemote":false,"IsSourceControlled":false}},
{"Key":"P:\\4SysUtils\\SysUtilsDll.sln","Value":{"LocalProperties":{"FullPath":"P:\\4SysUtils\\SysUtilsDll.sln","Type":0,"SourceControl":null},"Remote":null,"IsFavorite":false,"LastAccessed":"2020-03-30T20:07:43.1135728+00:00","IsLocal":true,"HasRemote":false,"IsSourceControlled":false}}
]
</value>

What I'm after is the value of the very first "FullPath" (which, above, is "P:\\Hello\\Hello.sln"). I can give that string to START. Can I use TCC's XML functions to dig that out of the file? I could use some help. I hope there's enough information above.

For anyone with DevStudio 2019, the file in question is (here)

Code:
%USERPROFILE\AppData\Local\Microsoft\VisualStudio\16.0_6b6f020f\ApplicationPrivateSettings.xml

Thanks.
 
That format is weird. It consists of a thin XML shell:
Code:
<collection name="CodeContainers.Offline">
  <value name="value">
  ...
  </value>
</collection>

with JSON inside:
Code:
  [
    { "Key"   : "P:\\Hello\\Hello.sln"
    , "Value" : { ...
                }
    }
  , ...
  ]

XML routines will be not be able to parse the JSON.
 
The wrapper is a little thicker; I didn't post the outer layers. I got something from TCC's XML functions but I can't go further. Below, the last command crashes TCC.

Code:
d:\tc26> echo h=%@xmlopen[c:\users\vefatica\appdata\local\microsoft\visualstudio\16.0_6b6f020f\ApplicationPrivateSettings.xml]
h=0

d:\tc26> echo %@xmlxpath[/content/indexed/collection]
*System.String*Visual Studio 6False

d:\tc26> echo %@xmlxpath[/content/indexed/collection[0]]
TCMD: (XML)  Line: 0; Char: 0   (null)
d:\tc26> echo %@xmlxpath[/content/indexed/collection]
*System.String*Visual Studio 6False

d:\tc26> echo %@xmlnodes[/content/indexed/collection]
2

d:\tc26> echo %@xmlxpath[/content/indexed/collection[1]]
*System.String*Visual Studio 6False

d:\tc26> echo %@xmlxpath[/content/indexed/collection[0]]
TCMD: (XML)  Line: 0; Char: 0   (null)
d:\tc26> echo %@xmlxpath[/content/indexed/collection[2]]

I can accomplish my goal by various other means.

A BTM (@FILEREAD) gives me the desired string in 2.9 seconds.
TPIPE (throw in some newlines, grep, head, replace) gets it in .5 second.
My own EXE gets it in .02 second.

The file is attached in case anyone wants to mess with it.
 

Attachments

  • vsxml.zip
    3 KB · Views: 258
I spent a little bit of time on this, but got nowhere. I suspect that these XML routines don't work as well as they might.

I would do this sort of thing with a different scripting language, such as Python or Perl or whatever you prefer, which have libraries that make it easy.
 

Similar threads

Back
Top