Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to get attribute values from child nodes in xml

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<?xml version="1.0" encoding="UTF-8"?>
<Export version="1.0" type="CTM-MAPPING">

<MetaData>
<MetaDataValue tagname="LeftConnection" id="1" name="My_First_Oracle_Connection"/>
<MetaDataValue tagname="RightConnection" id="2" name="My_Second_Oracle_Connection"/>
</MetaData>

<table >
<Column name="SRC_CONNECTION_ID" replace="CONNECTIONMAP" type="NUMERIC">1</Column>
<Column name="DEST_CONNECTION_ID" replace="CONNECTIONMAP" type="NUMERIC">2</Column>
<Column name="CREATED_BY" replace="DESTINATIONUSER" type="STRING">ADMIN</Column>
<Column name="CREATED_ON" type="DATE">null</Column>
<Column name="MODIFIED_BY" replace="DESTINATIONUSER" type="STRING">null</Column>
<Column name="MODIFIED_ON" type="DATE">null</Column>
<Column name="MAPPING_DATA" type="CLOB"><?xml version="1.0" encoding="UTF-8"?>
<base-mappings><predicates/><scripts/></base-mappings></Column>
<Column name="MAPPING_READ_DATA" type="CLOB"><?xml version="1.0" encoding="UTF-8"?>
<read-mappings><predicates/><scripts/></read-mappings></Column>
<Column name="MAPPING_WRITE_DATA" type="CLOB"><?xml version="1.0" encoding="UTF-8"?>
<write-mappings><predicates/><scripts/></write-mappings><design-mappings-xml><?xml version="1.0" encoding="UTF-8"?>
<design-mappings><predicates/><logical-units><logicalunit creation-date="10/03/2012 15:11:23" creator="ADMIN" mapping-name="design_test_1" name="design_test_1"><object id="Enterprise_Employee"mapping-name="design_test_1" name="Enterprise_Employee" x="-150"




The above is my sample xml file and i have to extract mapping name value from it but i am getting only column node from both sax and dom parser please help me how to extract it
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

kulbhushan patil wrote:i have to extract mapping name value from it but i am getting only column node from both sax and dom parser



Then there's a bug in your code and you need to fix it.

please help me how to extract it



Provide an SSCCE(←click) that has just enough code to show the problem, and nothing else, and indicate clearly observed and desired behavior.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pretty sure you can't just embed an XML doc inside another one though without at least using CDATA or something. Having this in the middle of your doc is likely to be problematic: <?xml version="1.0" encoding="UTF-8"?>
 
kulbhushan patil
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeff i have attached sample xml file which i have to parse and i have have to extract from it attribute named "mapping-name" from "logicalunit" node
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

kulbhushan patil wrote:Jeff i have attached sample xml file which i have to parse and i have have to extract from it attribute named "mapping-name" from "logicalunit" node



1. I see no attachment. Do you mean the XML in the body of your first post?

2. I'm not convinced you're starting with well-formed XML. If it's not well-formed, there's no point in trying to parse it.

3. I still don't see the SSCCE I asked for.
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, what you posted is not well-formed XML. So I agree with Jeff, that's most likely your problem.
    Bookmark Topic Watch Topic
  • New Topic