Link to home
Start Free TrialLog in
Avatar of akashj
akashj

asked on

Can PHP edit parts/nodes of XML?

HI all,
I am after a solution in order to be able to modify/edit XML nodes/sections via a PHP form.
The form would have several text boxes and when filled in/submitted, it would REPLACE a certain value in the XML.

The XML is initially extracted from a SQL Database table where it is stored as a blob I assume...

The XML itself is actually a Cognos report and I need maximum/minimum values changes on a Gauge chart.  Annoyingly, this is a cognos limitation whereby it cannot be linked to a value in a database table and so I need to modify this 24 times a day everyday manually.

What I want is to create a form which is tied to these maximum/minimum values so that it is easy to enter in a textbox and the report gets modified accordingly.
Once the submit is hit, I can then "update" the database table with the complete XML with the modifications that the form did.

I hope this makes sense!
Please see in the code section the type of XML it would be tied to

The solution would have to be to edit the value in <gaugeNumericalAxis max="8962"> (in this case 8692)
WHERE  refQuery="Query1

Then for Dial 2, it would be the same but for refQuery="Query2

etc etc
showTooltips="true" maxHotspots="10000" refQuery="Query1" name="Gauge Chart1">
<axisTitle refQuery="Query1">
<style>
<defaultStyles>
<defaultStyle refStyle="at"/>
</defaultStyles>
</style>
</axisTitle>
<gaugeNumericalAxis max="8962">
<gridlines color="#cccccc"/>
</gaugeNumericalAxis>

Open in new window

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

XML would probably be stored as TEXT, right?

Can you show us where you are on trying to code this yourself?  Getting a form to send input to PHP is one question, substituting the input form data into the XML string is another question, updating the data base with the modified string is another question - not quite sure where to start until you show us where you are right now.

Thanks and regards, ~Ray
Avatar of akashj
akashj

ASKER

Thanks for the reply
OK I'll try and answer the questions but it is a bit difficult explaining this...

Firstly, nothing has been coded at all.  My thinking was to do this via PHP somehow and link it but here would be the steps:

XML would be stored as text - correct.
Would it help if I attached the actual "report" which is in XML?
The way it works is you design the report in the tool (cognos) and it is stored in as XML.  You can test this by using an option to "copy report specification to clipboard" which when pasted in notepad, is in XML.  Pasting this back into the Cognos tool opens this report.

I managed to find out the table the report is stored in which is in one row and under one specific column.
This will be attached below however, if you simply right click and copy the "text" within the column, it is the same as extracting it via cognos.  Pasting this into cognos again opens up the report.

So now that we know that it is in a SQL table ...
My thinking is:
1. Connect to the database
2. Connect to the table and use a select query to the exactly point of where it is stored.  This is via an ID for that row.
3. This is where I now need textboxes to be able to connect to that specific node/s and update in there.

Does this help ?

Yes, it helps and my recommendation is that you either hire a developer (if you need this for a business purpose) or take some classes in HTML, XML, PHP and MySQL so you can get a foundation in these technologies.  You're a couple of college semesters away from fluency in the knowledge needed to do what you describe, but there is nothing in here that cannot be learned given enough time and concentration.  I can recommend two books that would be worthwhile (I own them both).
http://www.sitepoint.com/books/phpmysql4/
http://www.sitepoint.com/books/xml1/

You have a big task ahead of you.  It will be both a challenge and opportunity.  Best of luck with is, ~Ray
Avatar of akashj

ASKER

Makes sense - I should have said that I am actually good with HTML/PHP/MYSQL just not very good with the XML side -  especially in this context .
Thanks for the advice anyway!  Are you a developer yourself?
Yes, I am a developer, and I may be able to be helpful with the XML part of things.  If you can post the XML (all of it) and tell me a little about what you want to change, I can show you how to do that.
Avatar of akashj

ASKER

Please find attached the file
I have seen your work on here today and am confident you are the person to help out!  I actually noticed you have had similar queries so hopefully it should be a quick one.

I am willing to take this offline with you if it gets to a point that we do need to go via the developer route.

The attached txt file is what is stored in the DB...The parts that need to be in a form/modified are the

1. 6x <gaugeNumericalAxis max=
2. 14x discreteGaugePaletteValue


xml.txt
This does not appear to be valid XML, since it is missing the XML header!  But we can put that on the top, if it turns out to be needed.  Not sure about that - it may be parsed OK anyway.  I will try to isolate one of the parts you need to change and show you how to change it.  Back in a while...
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial