ozwolverine
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by ozwolverine
-
-
Thanks a lot,
I got very valuable information on it. -
Hello, I have to work with an OpenOffice 2 xml file like the shown below, I was wondering what is the best way (what libraries, packages to use) to be able to read it, look for certain tags, remove tags, add tags, and save the file again to disk?
[code]<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0">
<office:scripts/>
<office:font-face-decls>
<style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-pitch="variable"/>
<style:font-face style:name="Nimbus Roman No9 L" svg:font-family="'Nimbus Roman No9 L'" style:font-family-generic="roman" style:font-pitch="variable"/>
<style:font-face style:name="Nimbus Sans L" svg:font-family="'Nimbus Sans L'" style:font-family-generic="swiss" style:font-pitch="variable"/>
</office:font-face-decls>
<office:automatic-styles/>
<office:body>
<office:text>
<office:forms form:automatic-focus="false" form:apply-design-mode="false"/>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls>
<text:p text:style-name="Standard">página unica</text:p>
<text:p text:style-name="P1">Hoja2</text:p>
<text:p text:style-name="P1">Hoja3</text:p>
<text:p text:style-name="P1">Hoja4</text:p>
<text:p text:style-name="P1">Hoja5</text:p>
</office:text>
</office:body>
</office:document-content>
[/code]
Thanks a lot for any help,
-
Hello everybody,
I'm working with SimpleXMLElement to generate an xml file, but I'm having a problem, because all my tag names (odt xml files) have colons and dashes on it, for example: office:automatic-styles or style:style. the problem is because I use the following 'convention' to create child tags:
[code]$vendor = $xml-> mobil[0] -> addChild('vendor', 'Johnny');[/code]
where mobil[0] is the first tag named mobil on the root tag.
so If I want to add a new tag that has the name: office:automatic-styles, how could I scape the colon and the dash? if I write this:
[code]$style = $xml-> office:automatic-styles[0] -> addChild('style:style', '');[/code]
I get a bunch of errors.
I tried to scape them using a \ before each of these characters, but this didn't help.
Does anyone know what should I do?
I tryed putting the name of the tag in a string, but this does nothing, doesn't create the tag y the xml, nor throws any error message.
Help would be very appreciated.
Thanks
-
Now I'm able to write the full xml structure to a file, using this code that I found in another post:
[code]file_put_contents($apuntador, $xml->asXML());[/code]
Now the problem is generating the XML tags, They throw me that warning message:
[quote]Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in[/quote]
What is wrong in the tags generation code?
thanks a lot,
-
Hello everybody, I have this question:
I need to read (load) an xml file I have on disk, so I'm reading it with something like this:
[code]
$xml = simplexml_load_file($this->stylesXml);
[/code]
Now I need to add other tags to the already existent tags, So I to get that I wrote this code:
[code]
//New XML Tags
$documentContentTag = 'office:document-content';
$stylesTag = 'office:automatic-styles';
$styleTag = 'style:style';
$styleProps = 'style:paragraph-properties';
//Attributes (Name , value)
$styleAttrName = 'style:name';
$styleAttrVal = 'P1';
$styleAttrFamName = 'style:family';
$styleAttrFamVal = 'paragraph';
$styleAttrParentName = 'style:parent-style-name';
$styleAttrParentVal = 'Standard';
$stylePropsAttrName = 'fo:break-before';
$stylePropsAttrVal = 'page';
//Add tags to existent xml
$styles = $xml->$documentContentTag -> addChild($stylesTag, '');
//echo $xml->asXML();
$style = $styles -> addChild($styleTag,'');
$style->addAttribute($styleAttrName, $styleAttrVal);
$style->addAttribute($styleAttrFamName, $styleAttrFamVal);
$style->addAttribute($styleAttrParentName, $styleAttrParentVal);
$stylePropsChild = $style->addChild($styleProps,'');
$stylePropsChild->addAttribute($stylePropsAttrName, $stylePropsAttrVal);
[/code]
What I want to create is this structure:
[code]
<office:automatic-styles>
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
<style:paragraph-properties fo:break-before="page"/>
</style:style>
</office:automatic-styles>[/code]
in a existent tag (root tag) of the xml called: [code]</office:document-content>[/code]
But I have three problems:
1. I get this warning in the browser:
[tt]Warning: SimpleXMLElement::addChild() [function.SimpleXMLElement-addChild]: Node no longer exists in[/tt]
After the execution of the line: [code]$style = $styles -> addChild($styleTag,'');[/code] is executed
Why?
2. If I try to echo the XML file (including tags), I just get literals without tags :(. How could I do it?
3. If I write and XML file using something like:
[code]
if ($this->fp = fopen($fileName, 'w')) {
$this->fileSize = fwrite($this->fp,$this->content);
fclose($this->fp);
}[/code]
or read it in a similar way I just get literals without tags
What should I do?
Thanks a lot.
Problems with javascript versions 5.0.x and 5.1.x!!
in PHP Coding Help
Posted
Hello everybody, I have a problem javascript related.
I have a popup that has: one textbox and a select list, when the select changes I throw a submit(); I have a javascript function that first checks if both the textbox was filled and the select has change its value, and depending on that it constructs (using java script) another pop up that will show some number sequences.
The problem is that in my environment (Linux, php5.2.0, Oracle9i) it works perfectly well, so I mounted on another (in our client's machines) environment (Linux, php5.0.4, mssql) and it doesn't work. In client's system, after I make a selection in the select, it submits the page, but it returns some of the javascript code in the same popup. Let me explain with some code:
this is the whole page code:
The generated code of the page when the popup is loaded for the first time is:
but when I change the value of the select, after submit it shows me this code, see screenshot:
It seems like instead of creating the javascript source it tries to put it as part of the actual page (html) code.
The original popup is:
The popup after the submit of the onchange is:
What could the problem be? I guess it is not a client problem, because after the code didn't work I used the same machine in the client company to connect to the version I have working in my company, and it worked, so I think it is a problem of the PHP version, in my environment I have 5.2.0 the client has 5.0.4, A friend tried in php 5.1.6 and it didn't work there either
Any ideas?? Could this be a possible bug?
Thanks a lot,
Johnny