How do I grab this number with VBScript or JavaScript?

evildre

[H]F Junkie
Joined
Oct 23, 2000
Messages
13,345
Hey, all. I've never really worked with XML before, so I have no idea what I'm doing here :D
Code:
<?xml version="1.0"?><xml xmlns:s='uuid:FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'
	xmlns:dt='uuid:EEEEEEEE-EEEE-EEEE-EEEE-EEEEEEEEEEEE'
	xmlns:rs='urn:schemas-microsoft-com:rowset'
	xmlns:z='#RowsetSchema'>
<s:Schema id='RowsetSchema'>
	<s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'>
		<s:AttributeType name='ThisNumber' rs:number='1' rs:nullable='true' rs:writeunknown='true'>
			<s:datatype dt:type='int' dt:maxLength='4' rs:precision='10' rs:fixedlength='true'/>
		</s:AttributeType>
		<s:extends type='rs:rowbase'/>
	</s:ElementType>
</s:Schema>
<rs:data>
	[color=red]<z:row ThisNumber='123'/>[/color]

</rs:data>
</xml>

The code will only be running under Windows, maybe on 4 or 5 machines total. I've tried stuff with Microsoft.XMLDOM, but after reading up on it, I still have no clue how to get that last bit of information, highlighted in red. All I need is the value of ThisNumber in integer format. The XML file is located at a URL that doesn't change. How do I go about doing that?
 
You could make a regular expression from VBScript to extract it whether it appears once or many times in the file.

Do something like this:

Code:
    Dim RegExp, matches, match
    Set RegExp = CreateObject("VBScript.RegExp")

    RegExp.Pattern = "<your pattern>"
    RegExp.Global = True
    Set matches = RegExp.Execute(u)
    For Each match In matches
        ' do whatever you want with each extracted number in match.submatches(0)
    Next

Just replace <your pattern> with an appropriate regular expression.

edit: u above in RegExp.Execute contains text (use FSO to read the file), and an appropriate regular expression pattern would be: "\<z:row ThisNumber='(\d+)"
 
Back
Top