Getting XML tags
Hi,
I need to extract the list of the tags of an XML or DTD document. Do you know how could I do it?
For example, if I have:
<person>
<name></name>
<surname></surname>
<address></address>
</person>
i should obtain something like:
person, name, surname.
Or better a tree:
person
|
| | |
name surname address
Can anyone help me?
Thanx a lot.
Add xmlparserv2.jar to Classpath.
//Parse an XML document with a DOMParser.
DOMParser parser=new DOMParser();
parser.parse(new FileInputStream(new File("c:/input/input.xml")));
//Get the document parsed.
XMLDocument document=parser.getDocument();
//Get a node list of elements in the document.
NodeList nodeList=document.ElementsByTagName();
//List the elements in the document.
for(int i=0; i<nodeList.getLength(); i++)
System.out.println("Element "+ ((Element)(nodeList.item(i))).getTagName());
Similar Messages
-
Getting xml tags for PO releases.
I need some help in getting xml tags for PO releases.
When I refer metalink they gave me the following for Std PO.
Create a new Standard Purchase Order and DO NOT approve it. Let it be in Incomplete status. Go to
concurrent requests and run the 'PO Output for Communication' concurrent
program will the following parameters:
Print Selection: All
Purchase Order Number From: The PO # you just created
To: The PO # you just created
Test: Debug
May I know for PO releases what are additional parameters.I tried to enter release numbers in addition to the above.Bit it did not work,..
I am having issue in getting buyer contact phone for PO releases.So I am trying to see if the work_tele_phone is available for Po releases xml tags.
Can anyone please advise
prasambTo get the tag name, you can use the following XSL stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()">
<xsl:value-of select="name()"/> <xsl:text> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet> -
How to get XML tag attribute vaue in Oracle
Hi,
I have XML file which have order tag
<submitOrderRes>:Application Exception: SOS</submitOrderRes>.
From this xml file i want to display only the tag value , which is 'Application Exception: SOS'.
how to get this tag value by select SQL
any help is appreciate
TYI don't know your query
Here is the example
SQL> l
1 select
2 extractvalue(xmltype(dbms_xmlgen.getxml('select * from emp where rownum=1'))
3 ,'/ROWSET/ROW/ENAME') col_value
4* from dual
SQL> /
COL_VALUE
SMITHSS -
Hi,
I am trying to get the attribute values of an XML Tag of a Textbox. To get the xml tag of the selected element, I use
InterfacePtr<IXMLTagSuite> xmlTagSuite(fCurrentSelection,UseDefaultIID());
if (xmlTagSuite)
UIDList tagUIDList = xmlTagSuite->GetTags();
UID tagID;
UIDRef tagUIDRef;
for(int32 i=0; i < tagUIDList.Length();i++)
tagID = tagUIDList[i];
tagUIDRef = UIDRef(fCurrentSelection->GetDataBase(), tagID);
InterfacePtr<IXMLTag>xmlTag(tagUIDRef,UseDefaultIID());
if (kTrue == tagUIDRef.ExistsInDB()) {
tagName = xmlTag->GetTagName();
err = kSuccess;
since I am totally new to this, It would help a great deal if you could tell me how to iterate thourgh the attribute values of that tag.
Thanks so much in advance
Benny"Tags" are what appear in the Tags palette. "Elements" are what appear in the Structure View. Tags do not have attributes, elements are the ones with attributes. Instead of looking at the tags, you should be looking for the elements. Find the element that's associated with the story, and IIDXMLElement should have attributes you can loop through.
-
Getting Xml tag values based on procedure in parameter
Hi,
I have an XML file like bellow
<college>
<studenthistory>
<sno>100</sno>
<sname>jeff</sname>
<sdept>comp</sdept>
</studenthistory>
<studenthistory>
<sno>200</sno>
<sname>kelly</sname>
<sdept>physics</sdept>
</studenthistory>
</college>
i am writing a procedure like bellow
create or replace procedure p_test(studendtno number)as
val1 varcahr2(200);
val1 varcahr2(200);
xml_file sys.xmltype;
begin
xml_file:= XMLType(bfilename(testdirectory, 'test.xml'),
nls_charset_id('AL32UTF8'));
end;
i am able to get xml file from rempote to xml_file variable...
Now what i want is if i send 100 as in parameter just i want 100 related ename,edept values ,if i send 200 as in parameter i want 200 related values ename,edept.
output
val1 val2
jeff comp
kelly physics
Thanks
satya
Message was edited by:
satya81
Message was edited by:
satya81
Message was edited by:
satya81
Message was edited by:
satya81How about something like
SQL> create or replace procedure p_test (studendtno number, cur out sys_refcursor)
as
begin
open cur for
with xml_tab as
(select xmltype
('<college>
<studenthistory>
<sno>100</sno>
<sname>jeff</sname>
<sdept>comp</sdept>
</studenthistory>
<studenthistory>
<sno>200</sno>
<sname>kelly</sname>
<sdept>physics</sdept>
</studenthistory>
</college>') xml
from dual)
select t.column_value.extract ('studenthistory/sname/text()').getstringval() sname,
t.column_value.extract ('studenthistory/sdept/text()').getstringval() sdept
from xml_tab x,
table (xmlsequence (x.xml.extract ('college/studenthistory'))) t
where t.column_value.extract ('studenthistory/sno/text()').getnumberval() = studendtno;
end p_test;
Procedure created.
SQL> var cur refcursor
SQL> exec p_test(100,:cur)
PL/SQL procedure successfully completed.
SQL> print cur
SNAME SDEPT
jeff comp
1 row selected. -
How to get xml tag name?
Hi all
I've selected some texts and I want to get its xml element name not root element. I've done this
InterfacePtr<IXMLReferenceData> xmlRefData(Utils<IXMLUtils>()->QueryXMLReferenceData(textModel));
and I get only the document's root element name.
Any suggessions please.Hello Dirk
I've looked there. But I dont understand which one one will satisfy my need. There are "QueryDocElement" and "QueryRootElement" and their definitions say that it will return root element of doc/database.
please i need ur suggessions further.
Thanks
THAMIL -
How to change XML Tag sequence in XML Publisher Reports
Hi Experts,
I am working on XML Publisher reports, EBS 11I and Database 9i. I have standard report 'PO Printed Purchase Order Report (XML)', it's output type is XML. I want to change the sequence of groups in XML file.
I am getting XML tags like below at present:
LIST_G_HEADERS \ G_HEADERS \ LIST_G_HEADER_NOTES
I want to change the sequence of groups like below.
LIST_G_HEADERS \ G_HEADERS \ LIST_G_LINES \
Could somebody help me how to change the sequence of XML Groups.
Thanks in advance.Paul,
This works. Thanks!
I am still working through the implications of having a data connection defined. I notice that every time I submit, it creates two records in my database, one with all the fields blank, and one with the data and attachment.
I will have to do some more digging into the double submission, but at least it is uploading the file.
Thanks again,
Ed -
How to set xml tag to nothing in indesign using applescript?
Hi guys,
I need set xml tag to nothing(for tables) in indesign using applescript.
Please help me.Hi,
tell application "Adobe InDesign CC 2014"
tell active document
if (count of story) > 0 then
tell story 1
if (count of tables) > 0 then
tell table 1
set tag_name to associated XML element ----------------> i can't get xml tag, i am receiving the xml tag is nothing.
if (tag_name = nothing) then
display dialog ("This table has no tag")
else
set markup_tag to markup tag of tag_name
set n to name of markup_tag
display dialog ("Tag name is " & n)
end if
end tell
end if
end tell
end if
end tell
end tell
I can't get xml tag for table, i am received nothing -
Error While trying to Get XML element(tag) Values
We are trying to get XML element (TAG) value from the XML pay load.
Example.
Getting XML String from a web service and then converting into XML payload.
ora:parseEscapedXML(bpws:getVariableData('signOn_Out','signOnReturn'))
From this XML payload we are trying to get an element (Tag) value.
We are getting following error
Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
oracle.xml.parser.v2.XMLElement@118dc2a
{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
- <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
- <part name="summary">
<summary>
empty variable/expression result.
xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
</summary>
</part>
</selectionFailure>
Here are signOnReturn and XML Payload XSD's
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/Web1"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Web1ProcessRequest">
<complexType>
<sequence>
<element name="userName" type="string"/>
<element name="password" type="string"/>
</sequence>
</complexType>
</element>
<element name="Web1ProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
</sequence>
</complexType>
</element>
</schema>
<?xml version="1.0" encoding="windows-1252" ?>
<schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://xmlns.oracle.com/Web"
xmlns="http://www.w3.org/2001/XMLSchema">
<element name="TProcessResponse">
<complexType>
<sequence>
<element name="result" type="string"/>
<element name="User">
<complexType>
<sequence>
<element name="Id" type="string"/>
<element name="CompanyId" type="string"/>
<element name="SecurityToken" type="string"/>
<element name="FirstName" type="string"/>
<element name="LastName" type="string"/>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>I am sure and can see the data in audit trail.
[2006/12/12 09:17:36]
Updated variable "signOn_Output"
- <signOn_Output>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <WebMethodsProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</WebMethodsProcessResponse>
</part>
</signOn_Output>
Copy details to clipboard
[2006/12/12 09:17:36]
Updated variable "tririga"
- <tririga>
- <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</TririgaProcessResponse>
</tririga>
Copy details to clipboard
[2006/12/12 09:17:36]
Updated variable "Variable_2"
- <Variable_2>
- <part xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="payload">
- <TririgaProcessResponse xmlns="http://xmlns.oracle.com/WebMethods">
<Result xmlns="">
Success
</Result>
- <User xmlns="">
<Id>
2694069
</Id>
<CompanyId>
208133
</CompanyId>
<SecurityToken>
1165936654605
</SecurityToken>
<FirstName>
Jagan
</FirstName>
<LastName>
Rao
</LastName>
</User>
</TririgaProcessResponse>
</part>
</Variable_2>
Copy details to clipboard
[2006/12/12 09:17:36]
Error in evaluate <from> expression at line "130". The result is empty for the XPath expression : "/client:TririgaProcessResponse/client:User/client:LastName".
oracle.xml.parser.v2.XMLElement@1c8768e
Copy details to clipboard
[2006/12/12 09:17:36]
"{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure" has been thrown.
- <selectionFailure xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
- <part name="summary">
<summary>
empty variable/expression result.
xpath variable/expression expression "/client:TririgaProcessResponse/client:User/client:LastName" is empty at line 130, when attempting reading/copying it.
Please make sure the variable/expression result "/client:TririgaProcessResponse/client:User/client:LastName" is not empty.
</summary>
</part>
</selectionFailure>
Copy details to clipboard -
Getting unwanted values between the XML tags in XSLT mapping
Hi Folks
I have come across a very strange situation with my xslt mapping.
I am getting unwated values "11" between xml tags
as follows
<Tag>0001</Tag>
11
<DataID>3</DataID>
I am not sure why I am getting these values in between the tags. Any suggestions would be appreciated.Hi David,
Here is the code fragment where these 2 tags are mapped, FYI, the source is an IDOC message. The unwanted "11" is coming After the <Tag></Tag> and <DataID></DataID>. FYI, Fof the element <Tag></Tag> its a default value. But for <DataID> </DataID> I have the mapping logic.
<Order>
<OrderHeader>
<Tag>009</Tag>
<xsl:for-each select="E1EDKA1">
<xsl:choose>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U960'">
<DataID>
<xsl:value-of select="'1'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U300'">
<DataID>
<xsl:value-of select="'3'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U930'">
<DataID>
<xsl:value-of select="'1'" />
</DataID>
</xsl:when>
<xsl:when test="normalize-space(PARVW) = 'WE' and normalize-space(LIFNR) = 'U400'">
<DataID>
<xsl:value-of select="'3'" />
</DataID>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'1'" />
</xsl:otherwise>
</xsl:choose>
</xsl:for-each> -
How to get all xml tags in a text frame?
I want to get all the xml tags of the text in a text frame. I had tried the following methods but always get the tag binding the frame itself. <br /><br />1) XMLReference objXMLRef = Utils<IXMLUtils>()->QueryXMLReferenceData(textModel, 1);<br /><br />2) XMLReference objXMLRef = Utils<IXMLUtils>()->GetStoryThreadXMLReference(textModel, textIndex);<br /><br />Thanks in advance.
I would think if you intanciate the XMLReference and use IIDXMLElement GetChildCount / GetNthChild would do what you are looking for.
Ian -
Get position of xml-tag in clob
Hi,
Is it possible to get the offset in a clob, representing an xml, by using xml functionality? (function or xmltable)
For example, with a clob:
v_clob := '<a><b type="1">val1</b><b type="2">val2</b></a>';I would like a function like:
v_offset := xml_offset(v_clob,'/a/b[@type="2"]');With a result of 24 to get the tag, or 35 when asking for the actual value.
Thanks,
Jan
Edited by: BluShadow on 16-Jan-2013 15:22
added {noformat}{noformat} tags for readability. Please see {message:id=9360002} and learn to do this yourself in future.p.s. if you have an unknown XML structure and you need to parse it somehow, then you will likely be best using the DBMS_XMLDOM package and treating it as a DOM document so that you can recurse the hierarchy of tags, picking out the attributes and data as you go.
ETA: Example from my library of examples...
declare
v_xml XMLTYPE := XMLTYPE('<csg>
<ecrminput id="000000001">
<xml id="001" title="CustomerId">blah blah blah</xml>
<xml id="002" title="ContactId">blah blah blah</xml>
<xml id="003" title="CustomerNo">blah blah blah0</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="1027" title="Reservation Code">blah blah blah</xml>
<xml id="1028" title="Payment Reference">blah blah blah</xml>
<xml id="1029" title="Purchaser Customer Number">blah blah blah</xml>
</ecrminput>
<ecrminput id="000000002">
<xml id="001" title="CustomerId">blah blah blah</xml>
<xml id="002" title="ContactId">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="500" title="Attribute">blah blah blah</xml>
<xml id="1027" title="Reservation Code">blah blah blah</xml>
<xml id="1028" title="Payment Reference">blah blah blah</xml>
<xml id="1029" title="Purchaser Customer Number">blah blah blah</xml>
<xml id="1016" title="Call ID">blah blah blah</xml>
</ecrminput>
</csg>');
v_xsdoc DBMS_XMLDOM.DOMDocument;
v_dn DBMS_XMLDOM.DOMNode;
PROCEDURE processnode; -- forward declaration
PROCEDURE processattributes IS
nm DBMS_XMLDOM.DOMNamedNodeMap;
attr DBMS_XMLDOM.DOMAttr;
attnode DBMS_XMLDOM.DOMNode;
attname VARCHAR2(50);
attval VARCHAR2(250);
BEGIN
nm := DBMS_XMLDOM.GetAttributes(v_dn);
FOR i IN 0..DBMS_XMLDOM.GetLength(nm)-1
LOOP
attnode := DBMS_XMLDOM.Item(nm, i);
attr := DBMS_XMLDOM.MakeAttr(attnode);
attname := DBMS_XMLDOM.GetName(attr);
attval := DBMS_XMLDOM.GetValue(attr);
dbms_output.put_line('Attribute: '||attname||' Value: '||attval);
END LOOP;
END;
PROCEDURE parse_node_element IS
eltype VARCHAR2(100);
BEGIN
eltype := DBMS_XMLDOM.GetTagName(DBMS_XMLDOM.MakeElement(v_dn));
dbms_output.put_line('Tag: '||eltype);
processattributes;
processnode;
END;
PROCEDURE parse_node_text IS
BEGIN
DBMS_OUTPUT.PUT_LINE('Text: '||DBMS_XMLDOM.GetNodeValue(v_dn));
END;
PROCEDURE processnode IS
dnl DBMS_XMLDOM.DOMNodeList;
nt PLS_INTEGER;
BEGIN
dnl := DBMS_XMLDOM.GetChildNodes(v_dn);
dbms_output.put_line('Child Nodes Found: '||DBMS_XMLDOM.GetLength(dnl));
IF NOT DBMS_XMLDOM.IsNull(dnl) THEN
FOR i IN 0 .. (DBMS_XMLDOM.GetLength(dnl) - 1)
LOOP
v_dn := DBMS_XMLDOM.Item(dnl, i);
nt := DBMS_XMLDOM.GetNodeType(v_dn);
CASE
WHEN nt = DBMS_XMLDOM.ELEMENT_NODE THEN
parse_node_element;
WHEN nt IN (DBMS_XMLDOM.TEXT_NODE) THEN
parse_node_text();
ELSE
NULL; -- Unhandled node type;
END CASE;
END LOOP;
END IF;
END;
BEGIN
v_xsdoc := DBMS_XMLDOM.NewDOMDocument(v_xml);
v_dn := DBMS_XMLDOM.GetFirstChild(DBMS_XMLDOM.MakeNode(v_xsdoc)); -- <csg>
processnode;
END;
Child Nodes Found: 2
Tag: ecrminput
Attribute: id Value: 000000001
Child Nodes Found: 8
Tag: xml
Attribute: id Value: 001
Attribute: title Value: CustomerId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 002
Attribute: title Value: ContactId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 003
Attribute: title Value: CustomerNo
Child Nodes Found: 1
Text: blah blah blah0
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1027
Attribute: title Value: Reservation Code
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1028
Attribute: title Value: Payment Reference
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1029
Attribute: title Value: Purchaser Customer Number
Child Nodes Found: 1
Text: blah blah blah
Tag: ecrminput
Attribute: id Value: 000000002
Child Nodes Found: 8
Tag: xml
Attribute: id Value: 001
Attribute: title Value: CustomerId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 002
Attribute: title Value: ContactId
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 500
Attribute: title Value: Attribute
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1027
Attribute: title Value: Reservation Code
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1028
Attribute: title Value: Payment Reference
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1029
Attribute: title Value: Purchaser Customer Number
Child Nodes Found: 1
Text: blah blah blah
Tag: xml
Attribute: id Value: 1016
Attribute: title Value: Call ID
Child Nodes Found: 1
Text: blah blah blah
PL/SQL procedure successfully completed.Edited by: BluShadow on 16-Jan-2013 15:28 -
Adobe InDesign CS5 Server JavaScript: Get rectangle by XML tag
Hi,
Current set-up:
Adobe InDesign Server CS5 scripted through ExtendScript via PHP SOAP
The problem:
I'm currently placing an image file into a rectangle using the following code:
frame = doc.rectangles[0];
imgList = frame.place(new File(img));
This works fine; the img file is placed into the rectangle as expected. However, this only refers to the first rectangle in the document: if I have two rectangles in the document, the image is placed into the last created rectangle.
What I'd ideally like to be able to refer to the rectangle by its XML tag - something like:
frame = doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList = frame.place(new File(img));
Does anyone have any advice as to how this can be achieved? I realise this is rudimentary question, but am finding no joy after several hours of searching.
Many thanksWhat I'd ideally like to be able to refer to the rectangle by its XML tag - something like:
frame = doc.getRectangleByTag('Pic'); // <Pic> being the name of the XML tag
imgList = frame.place(new File(img));
Are you sure you want to do it this way?
Could you explain why? I suspect there is a better solution.
In any case, at least in my test case, the XML tag is associated with the image inside the frame and not the frame itself. So if you want the frame, you must get the image associated with the tag and then go up to the parent. This works in a simple test:
var frame =
app.activeDocument.xmlElements[0].
evaluateXPathExpression("//tennis")[0].
graphics[0].parent;
[object Rectangle] -
Getting characters in a particular xml tag type during Sax parsing.
How do I get the text within a certain XML tag using the parser. I can use the parser which will get me all the text in all the tags, but how do I get the ones I need only.
For example:
<channel id="south-east.bbc1.bbc.co.uk">
<display-name lang="en">BBC1</display-name>
<display-name>1</display-name>
</channel>
<programme start="20040217233500" stop="20040218000500 +0000" channel="south-east.bbc1.bbc.co.uk">
<title lang="en">Film 2004 with Jonathan Ross</title>
</programme>how do I get the text 'Film 2004 with Jonathan Ross' without getting the others?Well, the SAX parser just gives you the start/end tag
information to a handler, right? So if you just use
the SAX parser to get one item, then you could do it
by running thru the entire XML file to get that item
then get another item. Clearly this isn't the best
way to do it.... The handler should put the data for
the whole document into some data structure, or use
DocumentBuilder to get a Document object. I see. Yes, that is not the way to use SAX. It's kind of an inside out way of doing things. If you using SAX you should know everything that you want before parsing and grab all of them in one fell swoop.
If you want to get an in memory representation, the JDOM package is a whole lot eaiser to use than DOM. -
How to get a text between two XML tags?
Hello everybody!
I've got a problem! How can I extract a text that is between tags, like <myTag> My text </myTag> I have no problem to get the attributes inside the tags, however, i don't know how to get some text that is between tags. Here is my xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<tangram_request service_id="3">
<send keep_session="nada">
<source></source>
<destination>3196931566</destination>
<channel_id>2</channel_id>
<text>Teste ServerSocket!!!</text>
</send>
</tangram_request>
Now, there's a fragment of my code, which gets some tags' attributes:
DOMParser parser = new DOMParser();
InputSource resp = new InputSource(new StringReader(XML));
parser.parse(resp);
Document doc = parser.getDocument();
Node node =(doc.getElementsByTagName "tangram_request")).item(0);
if (node instanceof Element)
Element el = (Element) node;
service_id = el.getAttribute("service_id");
System.out.println("\n\nService_id="+service_id);
}else{System.out.println("Erro");}
node = (doc.getElementsByTagName("send")).item(0);
if (node instanceof Element)
Element el = (Element) node;
keep_session = el.getAttribute("keep_session");
System.out.println("keep_session="+keep_session);
}else{System.out.println("Erro");}
Now, I want to get the texte between <destination> ... </destination>
How could I do that?
Thanks a lot
CalegariThanks... It worked fine!!!
Now how can I get lots of <desctination>... I did something that haven't worked...
node = (doc.getElementsByTagName("destination")).item(0);
while(node.hasChildNodes())
destination = node.removeChild(node.getFirstChild()).getNodeValue();
System.out.println("destination="+destination);
And now, my XML is like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<tangram_request service_id="3">
<send keep_session="nada">
<source></source>
<destination>3196931566</destination>
<destination>3196931567</destination>
<channel_id>2</channel_id>
<text>Teste ServerSocket!!!</text>
</send>
</tangram_request>
Thanks so much!
Calegari
Maybe you are looking for
-
Java class specified for a rule not present in the archive path
While checking an implementation of configurator, I found a CX rule that has a java class associated with it oracle.apps.cz.cx.xxx.AVCX But, when I clicked the 'Choose class' button to check where this class is located, I am unable to find the same i
-
MacBook OS 10.7.5 stops getting Yahoo Mails from 1/13/15
My MB kept asking me for YM password. I typed in a few times, got irritated I just canceled. That was on 1/13/15. I could not get YM from that on. My iPad has no problem in getting YM. I had deleted and added YM a few times, no luck. I also rebooted
-
HT3773 Is it at all possible to run OS X in VirtualBox?
Hi all, I am running on an older machine running RedHat Linux, and I have VirtualBox (Which supports OS X). My video absolutely ***** (Intel Integrated) and I only have 1GB of memory to play with. With say only 512 MB, can OS X run on VBox?
-
Cant video chat with new bookPro across the house
Hello my brother just got a new MacBook Pro a few days ago, and the using iChat is simple and easy until we try the video chat, we have not had a successful one yet. I can send the invite to video chat and when he goes to accept there is an error on
-
Macros are still missing from this release of developer. By missing I mean you can't configure it. The functionality is still there. You can import your key settings from previous versions that had macros working and that key definition will still