XML Helpfile ?

Recommended Posts

Hi!

I'v been goin thru most of the xml related stuff on the forum and i feel its not as clear as things are in autoit's helpfile and moreover it gets confusing for a noob like me who just cant get pass after openin and readin the file.

I tried my hands on xml wrapper file but could only manage to get some of the functions working (a noob is at tryin/work).

Though the wrapper file has commented its syntax etc, but then there are certain things which just wont run. Havin some sorta working example and other related technical details (like in some cases things wont work or what to keep in mind while trying some particular function) could very help like it did in already well documented helpfile for other things.

In short, i'm wondering if at all xml related things will be inducted in helpfile ?

B'Rgrds!

Edited by neo291

I'm not a programmer. Just a Power User.

Share on other sites

And the lord said "My son, lend thine ear to me so I may speak the answer into it loudly", and you comply...swiftly, the lord grasps thine lobes and sternly asks: "What kind of example are you looking for man? Do I look like David Blane or something?"

Share on other sites

Now that you have "claimed" urself status of "lord" lets see if u could get any result when u typ XML in the helpfile's search box :-)

And then the deciple said "Lord, we are insignificant humans. Things you can do with just a click amazes us. We being ur creation, we need more info on how to live our ordinary scripts."

I'm not a programmer. Just a Power User.

Share on other sites

On a more serious note, the XML Dom Wrapper was never accepted as a standard UDF hence there is no support for it in the help file.

You tell me your goal and I will provide assistance.

Share on other sites

Gettin serious now.

I have to edit/delete/add one node in xml file based on only one critereon.

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

Herez that xml file :-

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

<version>119</version>

<timeZone>05-30</timeZone>

<dateTime>2008-06-18T19:07:35Z</dateTime>

<id>20</id>

<type>mac</type>

<mac>00-11-5b-02-09-69</mac>

<id>21</id>

<type>mac</type>

<mac>00-e0-20-7e-33-48</mac>

<id>22</id>

<type>mac</type>

<mac>00-d0-09-fb-33-9c</mac>

<id>23</id>

<type>mac</type>

<mac>00-16-ec-51-86-0b</mac>

<id>24</id>

<type>mac</type>

<mac>00-19-d1-29-22-b0</mac>

<id>25</id>

<type>mac</type>

<mac>00-1a-92-74-18-4c</mac>

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

For edit and delete i only need to update/match mac address.

To add one would have to find the highest <ID> and then put a node with next <ID> value with a new node.

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

Ok, Now u can laugh ur @ out for such simple thing

I'm not a programmer. Just a Power User.

Share on other sites

So far i have been only tryin xml related functions outta wrapper file.

Not much of a success.

This trial coding will tell u the amounta confusion it led me to.

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

#include <_XMLDomWrapper.au3>

#include <array.au3>

Dim $aName,$aValue,$strQry _XMLFileOpen("C:\Documents and Settings\Surjeett\Desktop\autoit\badwidthclients\addresses.xml")$modtitle = _XMLGetChildText("addressStorage/addresses/address")

;$field=_XMLGetField("addressStorage/addresses/address") ;$field=_XMLGetvalue("addressStorage/addresses/address")

;$field = _XMLGetAttrib("addressStorage/addresses","address") ;$field = _XMLGetAllAttrib("addressStorage/addresses/address/ip", $aName,$aValue, $strQry = "") ;$field = _XMLUpdateField("addressStorage/addresses/address/ip", "sdfsfs") ;working

;($path,$attrib)

$field = _XMLGetChildText("addressStorage/addresses/address/id") ;Msgbox(0, "",$modtitle[1])

;$field=_XMLCreateChildNode("addressStorage/addresses","address","sfSDF","sdfsdfsf") ;$field=_XMLGetChildNodes("addressStorage/addresses/address")

Msgbox(0, "", $field[1]) ;Msgbox(0,$aValue[1], $aName[1]) ;_XMLFileOpen("C:\Programme\EA GAMES\Battlefield 2142\mods\bf2142\mod.desc") ;$modtitle = _XMLGetChildText("mod/title")

;Msgbox(0, "", $modtitle[1]) ;$field=_XMLCreateChildNodeWAttr("addressStorage/addresses", "id", "id", "idwav")

;_XMLSetAutoSave

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

I'm not a programmer. Just a Power User.

Share on other sites

This would have been a lot easier for you if your xml was formatted differently:

Current:

<address>
<id>20</id>
<type>mac</type>
<mac>00-11-5b-02-09-69</mac>
</address>

Easier:

<address id=20>
<type>mac</type>
<mac>00-11-5b-02-09-69</mac>
</address>

Then you could just do:

Share on other sites

I'll have to test that out that if modified xml would work or not.

In the meantime, perhaps u cud just guide me abt what set of functions will be used with the existing format of the xml file.

Once i'll know what functions i need to dig further then atleast i just wont get carried away with other things which simply deviates me off the track.

I'm not a programmer. Just a Power User.

Share on other sites

This will get you started:

#include "_XMLDomWrapper.au3"

$sXMLFile = "addresses.xml"$result = _XMLFileOpen($sXMLFile) if$result = 0 then Exit

;Display old value
ConsoleWrite("Existing value: " & GetMac(23) & @CRLF)

;Overwrite mac value
UpdateMac(23, "####")

;Display new value
ConsoleWrite("New value: " & GetMac(23) & @CRLF)

;Display highest id
ConsoleWrite("Highest id: " & MaxId() & @CRLF)

;------------------------------
;FUNCTIONS
;------------------------------

;Update specific node with new mac address (Returns 0 on error, 1 on success)
Func UpdateMac($iId,$sMac)
Local $xPath = '//addresses/address[id="' &$iId & '"]/mac'
;Perform update
_XMLUpdateField($xPath,$sMac)
If @ERROR Then
Return SetError(1,0,0)
Else
Return 1
EndIf
EndFunc

;Retrieve mac of specified id
Func GetMac($iId) Local$xPath = '//addresses/address[id="' & $iId & '"]/mac'$sMac = _GetFirstValue($xPath) Return$sMac
EndFunc

;Retrieve id of highest node
Func MaxID()
Local $Max = 0$nodeArray = _XMLSelectNodes("//addresses/*")
;Write all nodes to console
For $X = 1 to$nodeArray[0]
$Current = _GetFirstValue('//addresses/address[' &$X & ']/id')
If $Current >$Max Then $Max =$Current
;ConsoleWrite("[" & $X & "]: " &$nodeArray[$X] & " id: " &$id & @CRLF)
Next

Return $Max EndFunc ;_XMLGetValue returns an array (not sure why) this will return the first element Func _GetFirstValue($node)
$ret_val = _XMLGetValue($node)
If IsArray($ret_val) Then Return ($ret_val[1])
Else
Return SetError(1,3,0)
EndIf
EndFunc
Edited by weaponx
Share on other sites

Thanx a tonnn!

This for sure gonna help me a lot!

-----------

N then the deciple said "Thank You My Lord! You saved ur pupil"

:-)

B'rgrds

I'm not a programmer. Just a Power User.

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