Jump to content

Recommended Posts

  • 2 weeks later...
Posted

Hey guys,

Forgive me... I haven't read all 38 pages of this thread to see if this is covered; I am using this wrapper as part of an RSS reader app. It is working great, except that at least once a week, I get the following error:

Line 451
$objNodeList = $objDoc.documentElement.SelectNodes($strXPath)
$objNodeList = ^ERROR
Error: Error in expression

Anyone know what this is, and/or if there's a way to exit the script gracefully if this error can't be avoided... I am not an AutoIt expert :)

  • 3 weeks later...
Posted (edited)

I don't understand this command:
 _XMLReplaceChild($objOldNode, $objNewNode[, $ns = ""])

What kind of object should I pass as $objOldNode and $objNewNode?

I tried like this but it gives error:

[...]
$old = $o.SelectSingleNode("/xml/abc")
$new = $o.SelectSingleNode("/xml/def")
_XMLReplaceChild($o, $old, $new)
[...]
Edited by Imbuter2000
  • 7 months later...
Posted (edited)

link is broken so I put here an latest version which I have.

_XMLDomWrapper.au3

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

mLipok,

If you tidy the script it will also stop Au3Check displaying errors.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Fixed more issue, and script minior clean up

_XMLDomWrapper.au3

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 month later...
Posted

  On 10/29/2013 at 7:14 PM, WorknMan said:

Hey guys,

Forgive me... I haven't read all 38 pages of this thread to see if this is covered; I am using this wrapper as part of an RSS reader app. It is working great, except that at least once a week, I get the following error:

Line 451

$objNodeList = $objDoc.documentElement.SelectNodes($strXPath)

$objNodeList = ^ERROR

Error: Error in expression

Anyone know what this is, and/or if there's a way to exit the script gracefully if this error can't be avoided... I am not an AutoIt expert :)

 

Tried the newest verison here, and got:

Line 460

$objNodeList = $objDoc.documentElement.selectNodes($strXPath)

Error: Error in expresison.

What does this mean?

These kinds of errors used to happen randomly with the old version, then it stopped working altogether a few days ago. Which is why I tried the new one.

  • 1 month later...
Posted (edited)

Hello,

reading 10 pages but can't understand how use wrapper for read this XML

<?xml version='1.0' encoding='UTF-8'?>
<CtiMonitor>
<UserInfo A="MILANO" U="565" ROLE="USER" />
<SesId>000201410172141406816</SesId>
<UserRecord abilis='MILANO' user='201' interface='CTIP'>
   <State>ONHOOK</State>
   <Alias>PO_Manzoni</Alias>
   <Num>201</Num>
   <ActionParameter>NONE</ActionParameter>
   <CallTry>
      <State>INACTIVE</State>
   </CallTry>
   <IfSubtype>POTS</IfSubtype>
   <IfSubtypePotsDevice>PHONE</IfSubtypePotsDevice>
   <SmsEnabled maxsmssplit='1' allowunicode='NO'>NO</SmsEnabled>
</UserRecord>
<UserRecord abilis='MILANO' user='504' interface='CTIP'>
   <State>ONHOOK</State>
   <Alias>DISPOSIZIONE_REDAZIONE</Alias>
   <Num>514</Num>
   <ActionParameter>NONE</ActionParameter>
   <CallTry>
      <State>INACTIVE</State>
   </CallTry>
   <IfSubtype>POTS</IfSubtype>
   <IfSubtypePotsDevice>PHONE</IfSubtypePotsDevice>
   <SmsEnabled maxsmssplit='1' allowunicode='NO'>NO</SmsEnabled>
</UserRecord>
<UserRecord abilis='MILANO' user='506' interface='CTIP'>
   <State>ONHOOK</State>
   <Alias>Sala_interviste</Alias>
   <Num>506</Num>
   <ActionParameter>NONE</ActionParameter>
   <CallTry>
      <State>INACTIVE</State>
   </CallTry>
   <IfSubtype>POTS</IfSubtype>
   <IfSubtypePotsDevice>PHONE</IfSubtypePotsDevice>
   <SmsEnabled maxsmssplit='1' allowunicode='NO'>NO</SmsEnabled>
</UserRecord>
</CtiMonitor>

best result so far is this :

#Include <_XMLDomWrapper.au3>
#include <Array.au3>
;#Include <user\_XMLDomMdi.au3>
;===============================================================================
;Phone example  by <Stephen Podhajecki gehossafats at netmdc com>
;===============================================================================
$msg = ""
Opt("MustDeclareVars", 1)
Local $phone = @ScriptDir & "\GetSesStatus.xml"
Local $oBs = _XMLFileOpen ($phone, "")
;Local $oBs = _XMLFileOpen ($phone,"",0); is using _XMLDomMdi.au3
If @error Then
    MsgBox(0, "Error", "There was an error opening the file.")
    Exit
EndIf
_GetCalls()
Exit
;===============================================================================
;Funcs
;===============================================================================
Func _GetCalls($sType = "Alias") ; fill the gui with the list.
    Local $i_Nodes = _XMLGetNodeCount ("//UserRecord/" & $sType)
    If $i_Nodes > 0 Then
        Local $sRet = _XMLSelectNodes ("//UserRecord/" & $sType)
        Local $x, $y[$i_Nodes], $z
        If IsArray($sRet) Then
            ;            _ArrayDisplay($sRet,"Node Names")
            GUISetState(@SW_LOCK)
            For $x = 1 To $sRet[0]
                $y[$x - 1] = _RetFirst(_XMLGetField ("//UserRecord/" & $sType & "[" & $x & "]"))
                ConsoleWrite($y[$x - 1] & @LF)
            Next
            GUISetState(@SW_UNLOCK)
            _ArrayDisplay($y, "Alias")
        EndIf
    EndIf
EndFunc   ;==>_GetCalls

Func _RetFirst($aArray) ; return first item in an array
    If IsArray($aArray) Then
        Return $aArray[1]
    EndIf
EndFunc   ;==>_RetFirst

but can't read single values. I want recover:

-----------------------------------------

user='201'

State='ONHOOK'

Alias='PO_Manzoni'

-----------------------------------------

user='504'

State='ONHOOK'

Alias='DISPOSIZIONE_REDAZIONE'

-----------------------------------------

user='506'

State='ONHOOK'

Alias='SALA_INTERVISTE'

-----------------------------------------

anyone can help me ?

thank you,

m.

Edited by myspacee
  • 2 months later...
Posted

I do not think this is supposed to be complicated but its making my brain explode.

Maybe this is overkill for what I want to do but I just have a simple .xml config file for some software and instead of having to train hundreds of users how to conifgure the software from the GUI I want to edit the xml file for them.

So I just need to search the .xml file to find the fields that will be like <gps>Disabled</gps> and change it to "Enabled" another program is some Bluetooth software that also uses xml config and I would need to set the File Transfer path, this one would not have a static entry as each user would have the default path set with their username as a part of it, so I assume I would search for the <before></after> using this instead of a "string"

But yeah, just have not graspted how to use this UDF just yet.

Posted (edited)

@ViciousXUSM,

Not sure if you figured out what you are trying to do but since no one has commented on this I will give it a stab. Your Question is a little vague but I have used the XML Wrapper a couple of times. I will post some Code that might help you out. I'm not an expert by anyones standards on XML but in order to use it you have to understand the hierarchy of the document and that there are paths you have to take to get to that object you want to Read or Write to. I use Microsoft Visual Studio Express to open my XML Documents. I'm sure you have your own program of choice. You just need to make sure that it indents your document it will make finding the path to the object you want much easier to see.

  Reveal hidden contents

Writing is pretty much the same thing. This line is from a different program but the $aArray is what is being written to the XML Document. Its just one more Parameter then the Read, its what you want to be written to the document.

_XMLSetAttrib("/gfx/group/multistateIndicator["&$Number&"]/states/state["&$y&"]", "value",$aArray[$y][2])

Hope this helps I don't spend much time on these forms.

Edit: Types in the Code

Edited by Yokes9

I suck at programming... But I try really hard! :imwithstupid:

Posted

Thanks for the stab, I think what complicates me is that most people are using loops, arrays and other features instead of straight up UDF like functions that I can later add into a more advanced code rather than break down code to the base.

I'll try and take the time to work with what you gave me and see if I can get it functional.

If not for one of the two things I needed I already have it working with _ReplaceStringinFile but the other is more advanced and could definitely take advantage of this xml wrapper. 

  • 2 months later...
Posted

I'm trying to use the XMLDOMWrapper to read multiple values from an XML file and can't get it to work. I keep getting "Error in expression"

Any ideas where I am going wrong?

Here is my code:

#include <File.au3>; File functions
#include <Array.au3>; Array functions
#include <_XMLDomWrapper.au3>;_XML Management functions
$loadXML = _XMLLoadXML("Response.xml")
$Node1= "/qdbapi/table/records/record/@id"
$Node1retval = _XMLGetValue($Node1)
_ArrayDisplay($Node1retval)
MsgBox(0,0,$Node1retval)
 
 
Here is my XML:
  <?xml version="1.0" ?>
- <qdbapi>
- <table>
- <records>
- <record>
 <f id="3">1</f>
 <f id="16">2</f>
 <f id="17">test</f>
</record>
</records>
 </table>
</qdbapi>

 

  • 1 month later...
Posted
  On 6/26/2014 at 10:47 PM, mLipok said:

Fixed more issue, and script minior clean up

_XMLDomWrapper.au3

​my stored version was:

Global Const $_XMLUDFVER = "1.0.3.87"

I found some newer version here:

https://raw.githubusercontent.com/Silvernine0S/FolderMenu3EX/master/Include/_XMLDomWrapper_.au3

there is:

Global Const $_XMLUDFVER = "1.0.3.97"

 

Please check and report here if this newer version have any Script Breaking Changes.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

and here :

Global Const $_XMLUDFVER = "1.0.3.98"

 

so, 

Please check newer version as there is many Script Breaking Changes.

for example:

Func _XMLGetChildNodes($strXPath)
...


Func _XMLGetChildNodes(ByRef $objDoc, $strXPath)
...

 

 

edit:
also found it here:

https://code.google.com/p/autoit-cn/source/browse/trunk/UserInclude/ACN_XMLDomWrapper.au3?r=894

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Wow, those global variable names are pretty awful for a UDF.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

I clean up this UDF version a little, and work in progress.

 

But in the meantime as 

_XMLTransform(...

do not work for me correctly so I make it in this way:

Func _XML_TransformNode($sXML_FileFullPath, $sXSL_FileFullPath, $sHTML_FileFullPath)
    Local $oXslDoc = ObjCreate("Microsoft.XMLDOM")
    Local $oXmlDoc = ObjCreate("Microsoft.XMLDOM")
    $oXslDoc.Async = False
    $oXmlDoc.Async = False
    $oXslDoc.Load($sXSL_FileFullPath)
    $oXmlDoc.Load($sXML_FileFullPath)
    Local $sHTML = $oXmlDoc.transformNode($oXslDoc)
    Local $hFile = FileOpen($sHTML_FileFullPath,$FO_OVERWRITE+ $FO_UTF8)
    FileWrite($hFile,$sHTML)
    FileClose($hFile)

EndFunc   ;==>_XML_TransformNode

 

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 3 months later...
Posted

As I say above, here is beta of new UDF version.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 month later...
Posted

please post your question here:

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...