vMix Forums
»
General
»
General Discussion
»
Pull selectedIndex from API
Rank: Member
Groups: Registered
Joined: 7/20/2020(UTC) Posts: 14 Location: Henfield
|
Hi All, I'm working on a new bit of script in which I'm pulling from the API XML for the first time, I'm getting the error Error Line 9: Object reference not set to an instance of an object.My guess at the moment is I'm not understanding the syntax for pulling info out of a XML path/line/appropriate term. At this stage I'm trying to pull the current selectedIndex of a List Input to then use in the rest of the script. Any guidance as to what I'm doing wrong is much appreciated. Thanks! Code:'Grab Selected Index Test
'load vMix API xml in to memory
dim xml as string = API.XML()
dim x as new system.xml.xmldocument
x.loadxml(xml)
'check slide number and display
dim CurrentSlide as String = (x.SelectSingleNode("//input[@title='holding']//selectedIndex").InnerText)
console.writeline(CurrentSlide)
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,249 Location: Belgium Thanks: 294 times Was thanked: 961 time(s) in 795 post(s)
|
The xpath is not refering to an existing node
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/23/2019(UTC) Posts: 561
Thanks: 62 times Was thanked: 131 time(s) in 119 post(s)
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,249 Location: Belgium Thanks: 294 times Was thanked: 961 time(s) in 795 post(s)
|
try (x.SelectSingleNode("//input[@title='holding']/@selectedIndex").Value)
But do what DMWKR said for future reference
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/20/2020(UTC) Posts: 14 Location: Henfield
|
Quote: The xpath is not refering to an existing node Yes, I'm presuming my xpath is incorrect.. Quote:try (x.SelectSingleNode("//input[@title='holding']/@selectedIndex").Value)
But do what DMWKR said for future reference This gave the same error. Error Line 9: Object reference not set to an instance of an object.I looked at the links DMWKR posted (thanks) and I'm already using the Scripting for Dummies examples (and others) as a reference, but what I don't understand at the moment it seems is the structure of the xpath in this instance. the xml line I'm working with is Code:<input key="e285d586-c76c-493f-90ed-1c34d2f6ce83" number="23" type="VideoList" title="holding - Socials.png" shortTitle="holding" state="Running" position="0" duration="0" loop="False" muted="True" volume="100" balance="0" solo="False" audiobusses="" meterF1="0" meterF2="0" gainDb="0" selectedIndex="1">
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/23/2019(UTC) Posts: 561
Thanks: 62 times Was thanked: 131 time(s) in 119 post(s)
|
Originally Posted by: MattGrover Code:<input key="e285d586-c76c-493f-90ed-1c34d2f6ce83" number="23" type="VideoList" title="holding - Socials.png" shortTitle="holding" state="Running" position="0" duration="0" loop="False" muted="True" volume="100" balance="0" solo="False" audiobusses="" meterF1="0" meterF2="0" gainDb="0" selectedIndex="1">
You are using "holding" as title. But the "title" is "holding - Socials.png", "shortTitle" would be "holding".
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/20/2020(UTC) Posts: 14 Location: Henfield
|
Goddammit I'm an idiot!
Thank you!
So looks like a combo of using the wrong title reference (hence why it didn't exist) and ALSO my formatting of "//selectedIndex" which didn't work, but changing it to "/@selectedIndex" as Doggy suggested makes the line work now. I'll do more research to understand the why
Thanks to both of you!
|
|
|
|
vMix Forums
»
General
»
General Discussion
»
Pull selectedIndex from API
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close