Jump to content

Recommended Posts

Posted (edited)
  On 2/2/2016 at 3:10 PM, GMK said:

I'm sorry if I wasn't clear, but I wanted _XML_Tidy to clean up only the indents and have no encoding or standalone attributes at all.  I guess I'm just asking if this is a feature that anyone else would appreciate and how to implement it if so.

Expand  

Please download new version, and check:  XML__Example_TIDY.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

i just downloaded your latest XML UDF  1.1.1.10 but when i do a syntax check on the xml.au3 i get these errors and i can also can't run any of the examples?

>"C:\Program Files\AutoIt3\SciTE\..\au3check.exe" -q "Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"
! Au3check doesn't support input files encoded as UTF8 with BOM: Z:\bots\_autoit\test\XML_1.1.1.10\ADO_CONSTANTS.au3
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(1889,40) : warning: $OBJ_NAME: possibly used before declaration.
    ElseIf ObjName($oAttributes, $OBJ_NAME)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(2556,16) : error: 'With' cannot be nested.
        With $oWriter
        ~~~~~~~~~~~~~^
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(2567,16) : error: 'With' cannot be nested.
        With $oReader
        ~~~~~~~~~~~~~^
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(2578,46) : warning: $ADOENUM_adReadAll: possibly used before declaration.
        $sXML_Return = .ReadText($ADOENUM_adReadAll)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(1889,40) : error: $OBJ_NAME: undeclared global variable.
    ElseIf ObjName($oAttributes, $OBJ_NAME)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3"(2578,46) : error: $ADOENUM_adReadAll: undeclared global variable.
        $sXML_Return = .ReadText($ADOENUM_adReadAll)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
Z:\bots\_autoit\test\XML_1.1.1.10\XML.au3 - 5 error(s), 2 warning(s)
>Exit code: 2    Time: 0.06984


Am i missing something? Do i have a wrong version? Or do is my AutoIt version wrong?

Posted

Which version of AutoIT and au3check.exe you are using, also SciTE 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

Posted (edited)

aha...

 

 

edit:
You forget to answer about AutoIt and au3check.exe version.

 

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

  • 4 weeks later...
Posted

New version:
 

  Quote

    2016/06/16
    "1.1.1.11"

    . NEW: Function: __XML_IsValidObject_DOMDocumentOrElement - mLipok
    . Changed: Function: _XML_SelectNodes - parameter validation __XML_IsValidObject_DOMDocumentOrElement - mLipok
    .         Currently _XML_SelectNodes can use relative XPath
    . Changed: Function: _XML_SelectSingleNode - parameter validation __XML_IsValidObject_DOMDocumentOrElement - mLipok
    .         Currently _XML_SelectSingleNode can use relative XPath
    . Refactored: Function: _XML_CreateComment - mLipok
    . Changed: Function: @error > $XML_ERR_COMERROR - mLipok
    . Fixed: Function: _XML_Array_GetNodesProperties - properly gets all attributes - mLipok
    .
    . EXAMPLES: New, and checked/refactored/fixed
    .    XML__Examples_TIDY.au3
    .    XML__Examples_User__asdf1nit.au3
    .    XML__Examples_User_coma.au3
    .    XML__Examples_User_Realm.au3
    .    XML__Examples_User_scila1996.au3
    .    XML__Examples_User_DarkAqua__Tasks.au3
 

Expand  

Download Link:

 

 

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

I am trying to update this XML file to set the Current version to "1.5.1.7f", the previous version to "1.5.1.7e" and update to "06/21/2016"

When i execute my code, the XML is not updated and i get an @error message of 21

Any help would be greatly appreciated. Please let me know if you need any more info. Thank you!

Here is the XML:

<?xml version="1.0" encoding="utf-8" ?> 
<MagellanClient>
	<Version Current="1.5.1.7e" Previous="1.5.1.7d" Updated="05/17/2016" ZipFile="Magellan.zip"/>
</MagellanClient>

Here is my AutoIt code:

#include "XML.au3"

; first you must create $oXmlDoc object
Local $oXMLDoc = _XML_CreateDOMDocument(Default)

; Load file to $oXmlDoc
Local $sXmlFile = @ScriptDir & "\Version.xml"
_XML_Load($oXMLDoc, $sXmlFile)

_XML_ReplaceChild($oXMLDoc, '/Version', 'Current="1.5.1.7f" Previous="1.5.1.7e" Updated="06/21/2016" ZipFile="Magellan.zip')

MsgBox(0,"",@error)

; TIDY xml and save result back to object
$oXMLDoc.loadXML(_XML_TIDY($oXMLDoc))

; View in default System Viewer
_XML_Misc_Viewer($oXMLDoc)

 

Version.xml

Posted

Try this snippet:

......
        Local $sXML_Content = _
                '<?xml version="1.0" encoding="utf-8" ?> ' & @CRLF & _
                '<MagellanClient>' & @CRLF & _
                '   <Version Current="1.5.1.7e" Previous="1.5.1.7d" Updated="05/17/2016" ZipFile="Magellan.zip"/>' & @CRLF & _
                '</MagellanClient>'
        _XML_LoadXml($oXMLDoc, $sXML_Content)
        If @error Then
            MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
        Else
            _XML_SetAttrib($oXMLDoc, '/MagellanClient/Version', 'Current', '1.5.1.7f')
            If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
            _XML_SetAttrib($oXMLDoc, '/MagellanClient/Version', 'Previous', '1.5.1.7e')
            If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))

            MsgBox(0, '', $oXMLDoc.xml)

            ; TIDY xml and save result back to object
            $oXMLDoc.loadXML(_XML_TIDY($oXMLDoc))

            ; View in default System Viewer
            _XML_Misc_Viewer($oXMLDoc)
        EndIf
......

 

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

  • 2 weeks later...
Posted

Show what you try so far .

btw.

Welcome to the forum.

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 weeks later...
Posted (edited)

I've been trying to make sense of this UDF (it seems that it's great, but without good examples or documentation I've been struggling to make good use of it), and in the process I'm pretty sure I found a bug:

The function _XML_GetValue returns an array whose last element is empty, and the first value that it's supposed to retrieve is missing. The first value is missing because it's overwritten by what ends up being the Count value of the results. I was able to fix it by shifting all of the values down one element (and thus using the otherwise empty element) before the count value is added. See below for the snippet I've added near the end of the function:

; START Fix
    Local $i
    For $i = UBound($aResponse) - 1 To 1 Step - 1
        $aResponse[$i] = $aResponse[$i - 1]
    Next
    ; END Fix
    
    ; Last two lines of the function
    $aResponse[0] = UBound($aResponse) - 1
    Return SetError($XML_ERR_OK, $XML_EXT_DEFAULT, $aResponse)

The first 4 lines of the snippet are what I've added, the last 2 lines are the last two lines in the function (I kept them in for context). I hope this helps.

Cheers,

Jeemo

Edited by Jeemo

An emoticon is worth a dozen words.

Posted

Wait my reply in 20-07-2016, maybe then I'll be sober, Now I go to sleep and in the morning it is my party time :)
 

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
  On 7/18/2016 at 11:55 PM, mLipok said:

Wait my reply in 20-07-2016, maybe then I'll be sober, Now I go to sleep and in the morning it is my party time :)
 

Expand  

In two days?! That's quite a party! Haha, enjoy. :)

An emoticon is worth a dozen words.

  • 2 months later...
Posted (edited)

Hi,

could someone help me with these basics? I took this one from above ...

#include "XML.au3"

Local $oXMLDoc = _XML_CreateDOMDocument(Default)

Local $sXML_Content = ''
        $sXML_Content &= '<?xml version="1.0" encoding="UTF-8"?> ' & @CRLF
        $sXML_Content &= '<MagellanClient>' & @CRLF
        $sXML_Content &= @TAB & '<Version Current="1.5.1.7e" Previous="1.5.1.7d" Updated="05/17/2016" ZipFile="Magellan.zip"/>' & @CRLF
        $sXML_Content &= '</MagellanClient>'

_XML_LoadXml($oXMLDoc, $sXML_Content)

If @error Then
    MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
Else
    _XML_SetAttrib($oXMLDoc, '/MagellanClient/Version', 'Current', '1.5.1.99')
    If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
    _XML_SetAttrib($oXMLDoc, '/MagellanClient/Version', 'Previous', '1.5.1.98')
    If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))

    MsgBox(0, '', $oXMLDoc.xml)

    ; TIDY xml and save result back to object
    $oXMLDoc.loadXML(_XML_TIDY($oXMLDoc))

    ; View in default System Viewer
    _XML_Misc_Viewer($oXMLDoc)

EndIf

 

... and i get this:

 

<MagellanClient>
    <Version Current="1.5.1.99" Previous="1.5.1.98" Updated="05/17/2016" ZipFile="Magellan.zip"/>
</MagellanClient>

 

Even writing to file looses the first line: <?xml version="1.0" encoding="UTF-8"?>

 

Edited by TJF
Posted
#include "XML.au3"

Global $oXMLDoc = _XML_CreateDOMDocument()

Global $sXML_Content = '<?xml version="1.0" encoding="UTF-8"?> ' & @CRLF
        $sXML_Content &= '<MagellanClient>' & @CRLF
        $sXML_Content &= @TAB & '<Version Current="1.5.1.7e" Previous="1.5.1.7d" Updated="05/17/2016" ZipFile="Magellan.zip"/>' & @CRLF
        $sXML_Content &= '</MagellanClient>'

_XML_LoadXml($oXMLDoc, $sXML_Content)

If @error Then
    MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
Else
    _XML_SetAttrib($oXMLDoc, '//Version', 'Current', '1.5.1.99')
    If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))
    _XML_SetAttrib($oXMLDoc, '//Version', 'Previous', '1.5.1.98')
    If @error Then MsgBox(0, '', _XML_ErrorParser_GetDescription($oXMLDoc))

    Global $sNewXML = _XML_Tidy($oXMLDoc, 'UTF-8')
    MsgBox(0, 'New XML', $sNewXML)

    ; TIDY xml and save result back to object
    _XML_LoadXml($oXMLDoc, $sNewXML)

    ; View in default System Viewer
    _XML_Misc_Viewer($oXMLDoc)
EndIf

 

Posted

Thank you!

But now I get an ANSI-File and it looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><MagellanClient>
    <Version Current="1.5.1.99" Previous="1.5.1.98" Updated="05/17/2016" ZipFile="Magellan.zip"/>
</MagellanClient>

In the first line is "standalone="no" and after that tag, line doesn't break...

Posted

Show how you try to do this.

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

Oh... sorry! I was in the wrong folder. It is not ANSI. It's UTF-8 ...

But I don't understand, where In the first line the "standalone="no" comes from and after that tag, line doesn't break...  Like this:

<?xml version="1.0" encoding="UTF-8"?>
<MagellanClient>
    <Version Current="1.5.1.99" Previous="1.5.1.98" Updated="05/17/2016" ZipFile="Magellan.zip"/>
</MagellanClient>

 

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
×
×
  • Create New...