Jump to content

Recommended Posts

Posted

So, does anybody have any ideas about my previous post? On my last question, I've thought about possibly using _XMLgetAllAttrib and using the resultant arrays, but what would allocate the matching XML parts to memory in the array, correct? I don't want to use memory for something that's already stored somewhere else (in XML) if I don't have to. Thanks in advance!

Posted

You currently need to use the MDI version of this UDF to handle multiple files, otherwise you have to call XMLFileOpen every time you need to switch to a new file. Eltorro is supposed to be working a completely new version of this UDF that would handle multiple files.

Posted (edited)

Hi,

is it possible to write a namespace extension? And is it possible to write an XSD?

Something like this: (with xs: at the beginning)

<?xml version="1.0" encoding="utf-8" ?> - <!-- This file was generated by W3C XML/XSD Export Model Bridge from Meta Integration Technology, Inc. (MITI) --> f(clean); - <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns=""> - <xs:complexType name="Tabelle_1_LABEL"> <xs:attribute name="Tabelle_1_ATTR_1_LABEL" default="1000" type="xs:integer" /> - <xs:attribute name="Tabelle_1_ATTR_2_LABEL"> - <xs:simpleType> - <xs:restriction base="xs:string"> <xs:maxLength value="5" /> </xs:restriction> </xs:simpleType> </xs:attribute> - <xs:attribute name="Tabelle_1_ATTR_3_LABEL" type="xs:date"> - <xs:annotation> <xs:documentation>Dies ist das 3te Attribut</xs:documentation> </xs:annotation> </xs:attribute> - <xs:attribute name="Tabelle_1_ATTR_4_LABEL" type="xs:boolean"> - <xs:annotation> <xs:documentation>Dies ist das 3te Attribut</xs:documentation> </xs:annotation> </xs:attribute> </xs:complexType> - <xs:complexType name="Tabelle_2_LABEL"> - <xs:attribute name="Tabelle_2_ATTR_1_LABEL"> - <xs:simpleType> - <xs:restriction base="xs:string"> <xs:maxLength value="5" /> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> - <xs:element name="Tabelle_1_LABEL" type="Tabelle_1_LABEL"> <xs:annotation /> - <xs:key name="PrimaryKey"> <xs:selector xpath=".//Tabelle_1_LABEL" /> <xs:field xpath="@Tabelle_1_ATTR_1_LABEL" /> </xs:key> </xs:element> - <xs:element name="Tabelle_2_LABEL" type="Tabelle_2_LABEL"> <xs:annotation /> </xs:element> </xs:schema>

Thanks!

Mega

Edited by Xenobiologist

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

  • 3 weeks later...
Posted

Having some trouble with my XML file. It seems that XMLDomWrapper does not like the '&' character in my XML. For example if I have the XML file below, I get an error when trying to open the file. If I remove the '&' then it works fine. Is this a limitation with XML in general (since I'm not too familier with XML) or is this just a bug with XMLDomWrapper? Is there a way to write a quick fix? Thanks

<Test>

<Test2>

<ID>FNA934NFc7ND</ID>

</Test2>

<Test3>

<ID>2340GSFN301F</ID>

</Test3>

<Test4>

<ID>5&38E3519A&0&0.0.0</ID>

</Test4>

</Test>

  • 1 month later...
Posted (edited)

this could really help for those that do not know xml...

XPATH

http://www.w3schools.com/XPath/xpath_syntax.asp

XML

http://www.w3schools.com/xml/default.asp

I advice to add this to the fist page.

Edited by oren
  • 4 weeks later...
Posted (edited)

Hello

i am working with _XML_DOM for some while until now only for read nodes and child nodes and attributes

now i have XML that need to be updated and add data also but its seems that i am still confused with all those xml terms, i am posting xml example of what i need to be done

if someone could help by indicating which function is suitable for doing the job

thanks in advanced

***************xml example*************************

<chart>

<axis_category skip='value to change' color='CDE472' size='8'/>

<axis_ticks value_ticks='true' category_ticks='false' major_thickness='2' minor_thickness='1' minor_count='1' minor_color='222222' position='outside' />

<axis_value shadow='low' min='0' max='120' size='10' color='ffffff' alpha='50' steps='6' suffix='MB/s'/>

<chart_border top_thickness='2' bottom_thickness='2' left_thickness='2' right_thickness='2' />

<chart_data>

<row>

<null/>

<string>1sec</string> <-need to both the <string>1sec</string>

<string>2sec</string>

<string>3sec</string>

</row>

<row>

<string>Sent Speed</string>

<number shadow='low' tooltip='10'>10</number>

<number tooltip='12'>12</number> <-need to both the <number tooltip='12'>12</number>

</row>

<row>

<string>Receive Speed</string>

<number shadow='high' tooltip=''>30</number>

<number tooltip='32'>32</number>

</row>

</chart_data>

<chart_grid_h alpha='10' thickness='1' type='solid' />

<chart_grid_v alpha='10' thickness='1' type='solid' />

<chart_guide horizontal='true' thickness='1' color='ffffff' alpha='50' type='dashed' radius='5' line_color='FFFF00' line_alpha='75' line_thickness='2' text_h_alpha='0' />

<chart_note type='bullet' size='11' color='AAAAFF' alpha='90' x='0' y='-125' offset_y='5' background_color='8888FF' background_alpha='65' shadow='low' />

<chart_pref line_thickness='2' point_shape='none' fill_shape='false' />

<chart_rect x='60' y='20' width='335' height='200' positive_color='000000' positive_alpha='30' bevel='bg' />

<chart_type>Line</chart_type>

<draw>

<text layer='foreground' color='CAFF70' alpha='15' rotation='0' size='12' x='-30' y='220' width='300' height='150' h_align='center' v_align='top' shadow='low' bold='true'delay='1' transition='slide_left'>text to modify</text>

<text color='FFFFFF' alpha='15' rotation='0' size='12' x='-26' y='234' width='300' height='150' h_align='center' v_align='top' shadow='low' bold='true'delay='1' transition='slide_left'>text to modify</text>

</draw>

<filter>

<shadow id='low' distance='2' angle='45' alpha='50' blurX='5' blurY='5' />

<shadow id='high' distance='5' angle='45' alpha='25' blurX='10' blurY='10' />

<bevel id='bg' angle='45' blurX='15' blurY='15' distance='5' highlightAlpha='25' highlightColor='ffffff' shadowAlpha='50' type='outer' />

</filter>

<legend x='70' y='1' width='200' height='7' layout='horizontal' margin='5' size='9'/>

<tooltip color='FFFF00' alpha='70' size='12' background_alpha='0' shadow='low' />

<series_color>

<color>77bb11</color>

<color>cc5511</color>

</series_color>

</chart>

Edited by tbaror
Posted (edited)

Great udf , it was very useful to me , however i would like to give u a suggestion...

I used this udf to write big xml files , and i noticed that the script waste a lot of time in saving the xml every time i change something , everytime i add a node , change an attribute or something , the file is being saved.

So for example if i'm adding 10 nodes in a row there will be 9 unuseful saves that will waste a lot of time , so it could be useful to add a parameter to every function that allows u to specify if u would like the file to be saved or not.

Anyway , thank you for this udf! :(

Oups!

I notice just now _XMLSetAutoSave($bSave = True) function and _XMLSaveDoc in the last version , i was looking inside an old version i think :P sorry

Edited by N4rk0
Posted (edited)

this could really help for those that do ***************xml example*************************

<chart>

<axis_category skip='value to change' color='CDE472' size='8'/>

<axis_ticks value_ticks='true' category_ticks='false' major_thickness='2' minor_thickness='1' minor_count='1' minor_color='222222' position='outside' />

<axis_value shadow='low' min='0' max='120' size='10' color='ffffff' alpha='50' steps='6' suffix='MB/s'/>

<chart_border top_thickness='2' bottom_thickness='2' left_thickness='2' right_thickness='2' />

<chart_data>

<row>

<null/>

<string>1sec</string> <-need to both the <string>1sec</string>

<string>2sec</string>

<string>3sec</string>

The first vaule u want to change is an attribute , so u have to use _XMLSetAttrib

The second one is the node field , u have to use _XMLUpdateField

Edited by N4rk0
  • 2 weeks later...
Posted (edited)

Hi,

This UDF seems to be what I am looking for. I downloaded it and included it in my script.

I am trying to read information and write information to and from an XML file.

I need to get the "next" value from my <list> node. I don't know how to do that.

I also need to get the Name of the person from the <item> node.

I am trying to do that using this code snippet:

CODE
$sFile= "Admin\Tel\Tel.xml"

$ret = _XMLFileOpen ($sFile)

if $ret =0 then

MsgBox(4096, "File Open Error", "Error Opening File. Exiting program")

Exit

EndIf

$attr=_XMLGetAttrib("/list/item", "Nom")

MsgBox(0, "NAME", $attr)

This is how my xml file looks like

<?xml version="1.0" encoding="windows-1252"?>

<list next="566" timestamp="3981" schemastamp="23">

<Schema next="15">

<ElementType name="item">

<element id="s1" type="id" display="No"/>

<!-- must have an id on every row -->

<element id="s2" type="Name" display="Yes" values=""/>

<element id="s3" type="Gname" display="Yes" values=""/>

<element id="s4" type="Ext1" display="Yes" values=""/>

<element id="s5" type="Ext2" display="Yes" values=""/>

<element id="s6" type="Notes" display="Yes" values=""/>

<element id="s7" type="Dept" display="Yes" values=""/>

<element id="s8" type="Dept2" display="No" values=""/>

<element id="s9" type="Keyword" display="No" values=""/>

<element id="s10" type="temp" display="No" values=""/>

<element id="s11" type="LoginName" display="Yes" values=""/>

</ElementType>

</Schema>

<item>

<id>1</id>

<Name>Lambert</Name>

<Gname>Johnny</GName>

<Ext1>3454</Ext1>

<Ext2></Ext2>

<Notes/>

<Dept>TI</Dept>

<Dept2>IT</Dept2>

<Keyword>Lambert</Keyword>

<temp>

</temp>

<LoginName>jlambert</LoginName>

</item>

</list>

[EDIT - Added on October 24 2008] - I forgot to mention that I do not get any error when I do this, but the output in the message box is just empty. I don't really know why. It would mean that there is no such entry in the XML file or that it is not reading properly (which means I am not coding it properly).

If anyone knows what I am missing, I'd truly appreciate.

Thanks.

the123punch

Edited by the123punch
Posted

Hello,

i have problem with _XMLCreateChildNode function

i have below code to modify below xml

#include <GUIConstants.au3>
#include <_XMLDomWrapper.au3>
$sXMLFile = @ScriptDir & "\DelaTemp.xml"

$test ="<string>1sec</string>"
$result = _XMLFileOpen($sXMLFile)
if $result = 0 then Exit

Dim $str 

$rootPath = '/chart/chart_data[1]/row[2]/string[1]'

$rootPath1 = '/chart/chart_data[1]/row[2]/string[1]/number'
For $i = 1 To 3
    
_XMLCreateChildNode($rootPath, 'number', $i)


_XMLSetAttrib($rootPath1,'bevel','blue')
_XMLSetAttrib($rootPath1,'shadow','high')

_XMLSetAttrib($rootPath1,'tooltip',$i & 'ms')

Next     
_XMLSaveDoc($sXMLFile)

<chart>
    
    <chart_data>
        <row>
            <null/>
            <string>1</string>
            <string>2</string>
            
        </row>
        <row>
            <string>Ping Stream</string>

        </row>
    </chart_data>

the desired result should looks below xml

<row>
            <string>Ping Stream</string>
<number bevel="blue" shadow="high" tooltip="7ms">1</number>
<number bevel="blue" shadow="high" tooltip="7ms">2</number>
<number bevel="blue" shadow="high" tooltip="7ms">3</number>


        </row>
    </chart_data>

but i am getting this result

<row>
            <string>Ping Stream<number bevel="blue" shadow="high" tooltip="7ms">1</number>
<number bevel="blue" shadow="high" tooltip="7ms">2</number>
<number bevel="blue" shadow="high" tooltip="7ms">3</number>
<number bevel="blue" shadow="high" tooltip="7ms">4</number>
<number bevel="blue" shadow="high" tooltip="7ms">5</number>
<number bevel="blue" shadow="high" tooltip="7ms">6</number>
<number bevel="blue" shadow="high" tooltip="7ms">7</number>
</string>
        </row>
    </chart_data>

please advice how to get required result

thanks

Posted

Its doing what you are telling it to...change this:

$rootPath = '/chart/chart_data[1]/row[2]/string[1]'

to

$rootPath = '/chart/chart_data[1]/row[2]'

Posted

I don't know, make sure you have _XMLDomWrapper.au3 and TemplateData.xml in the same folder as your script. Maybe compile the script as Unicode instead of ANSI.

Posted

_XMLTransform() not working for me.

I ran the test code (above) and this don't produce any XML file("XML_NEW.xml"). Nor runtime errors.

The XML file is OK. Any tip?

#include <_XMLDomWrapper.au3>

$XmlFile= @ScriptDir & "\_XMLExample.au3.xml"
$oXmlFile = _XmlFileOpen ($XmlFile)
_XMLTransform ($oXmlFile,"", @ScriptDir & "\XML_NEW.xml")
$oXmlFile = 0
  • 2 weeks later...
Posted

Hey everyone. I'm sorry, but I've been fidgeting around with this script since last night and have made no progress understanding the functions.

I have an xml file that looks like this:

CODE
<?xml version="1.0" encoding="UTF-8"?>

<feed xmlns="http://www.w3.org/2005/Atom" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:base="http://www.w3.org/2005/Atom">

<title>[Product] Usage Reporting for 2008-11-5</title>

<link rel="self" type="application/atom+xml" href="http://[product site]/atom/usage-reporting?date=2008-11-5" />

<id>[Product]</id>

<generator>[Product] Suite</generator>

<updated>2008-11-07T04:01:05Z</updated>

<entry>

<content type="html"><div class='id'></div>

<div class='joinedDate'>Mon Dec 30 11:11:32 EST 2007</div>

<div class='activity'>Find</div>

<div class='activityDate'>2008-11-05 23:59:53.441</div></content>

</entry>

<entry>

<content type="html"><div class='id'></div>

<div class='joinedDate'>Mon Dec 31 11:16:17 EST 2007</div>

<div class='activity'>Reach</div>

<div class='activityDate'>2008-11-05 23:59:37.73</div></content>

</entry>

The areas that are in brackets will be filled in with the according information, so don't worry about them. I'm making a script that converts .atom (xml format) files to Excel Spreadsheats for a project a friend of mine is doing. For whatever reason, when I do _XMLGetChildNodes("/feed"), it completely skips Link and Generator.

What I need to do is store the 'ID', 'JOINED DATE', 'ACTIVITY', and 'ACTIVITY DATE' content contained in each ENTRY (of which there are many hundred) into an array. I have attempted this, but to be honest, I'm having a lot of trouble understanding the functions in this UDF and when to use them based on the rather frustrating descriptions provided, as I am not an expert at xml structure.

Thank you to everyone who helps out :mellow: and thank you for an awesome UDF

Posted

damn i just can not figure this out... to get the values out of the YouTube XML file as i keep getting errors -1.

Dude, stop quoting the code in your posts, I can't tell which is the original any more. Anyways, Dreamweaver says your xml is invalid, here is the error:

Line 39: Unterminated entity reference

Line 39: Entity 'f' was not found[xml]

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...